HDOJ 3652 B-number】的更多相关文章

题目传送门 /* 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; int a…
[HDOJ 3652]B-number 给一整数n 找<=n的整数中能被13整除且含有13的 数位dp 记忆化! . 一入记忆化深似海. ..再也不想用递推了...发现真的非常好想 仅仅要保证满足条件把未选高位(即能任意挑数的)记录下来 不断搜索递归即可 代码例如以下: #include <iostream> #include <cstdio> #include <cstring> using namespace std; int dp[10][13][3]; i…
数位DP... Balanced Number Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1337    Accepted Submission(s): 583 Problem Description A balanced number is a non-negative integer that can be balanced…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5930    Accepted Submission(s): 4146 Problem Description As we know, Big Number is always troublesome. But it's really important in our…
Problem Description In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of…
Problem Description Welcome to 2006'4 computer college programming contest! Specially, I give my best regards to all freshmen! You are the future of HDU ACM! And now, I must tell you that ACM problems are always not so easy, but, except this one- Ha-…
当进制转换后所剩下的为数较少时(2位.3位),相应的base都比較大.能够用数学的方法计算出来. 预处理掉转换后位数为3位后,base就小于n的3次方了,能够暴力计算. . .. Lucky Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 521    Accepted Submission(s): 150 Probl…
静态区间第K小....划分树裸题 Kth number Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5341    Accepted Submission(s): 1733 Problem Description Give you a sequence and ask you the kth big number of a int…
B-number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1561    Accepted Submission(s): 854 Problem Description A wqb-number, or B-number for short, is a non-negative integer whose decimal form…
dp [ x ] [ y ] [ z ] 表示二进制y所表示的组合对应的之和mod x余数为z的最小数... 如可用的数字为 1 2 3 4...那么 dp [ 7 ] [ 15 ] [ 2 ] = 1234 .... 输入一个数列后..将dp的表做出来..然后O(1)的输出...题目要求是( T + X ) % K =0 可以转化为 T % K = ( K - ( X % K ) ) % K Program: #include<iostream> #include<stdio.h>…
\(\\\) \(Description\) \(T\)组数据,每次给出一个正整数 \(N\) ,判断其是否能被任意一个完全平方数整除. \(T\le 20,N\le 10^{18}\) \(\\\) \(Solution\) 比较巧妙. 考虑一个数能被完全平方数整除,当且仅当对其分解质因数以后,至少有一个质数的指数\(\ge 2\). 借用试除法分解质因数的思路,大于\(\sqrt N\)的质因子至多只有一个.那么,大于 \(\sqrt[3] N\) 的质因数的平方整除 \(N\) 的个数至多…
题目传送门 /* 求逆序数的四种方法 */ /* 1. O(n^2) 暴力+递推 法:如果求出第一种情况的逆序列,其他的可以通过递推来搞出来,一开始是t[1],t[2],t[3]....t[N] 它的逆序列个数是N个,如果把t[1]放到t[N]后面,逆序列个数会减少t[1]个,相应会增加N-(t[1]+1)个 */ #include <cstdio> #include <cstring> #include <algorithm> using namespace std;…
题目传送门 /* Rabin_Karp:虽说用KMP更好,但是RK算法好理解.简单说一下RK算法的原理:首先把模式串的哈希值算出来, 在文本串里不断更新模式串的长度的哈希值,若相等,则找到了,否则整个模式串的长度的哈希值向右移动一位 */ /************************************************ * Author :Running_Time * Created Time :2015-8-5 14:04:26 * File Name :HDOJ_1711.…
Number Sequence Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8600    Accepted Submission(s): 3953 Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[…
后缀数组求不重复回文子串数目.注意dp数组. /* 3948 */ #include <iostream> #include <sstream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <deque> #include &l…
终于自己写出来一道数位DP啊.继续训练DP. /* 3652 */ #include <iostream> #include <sstream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <deque> #include &l…
神一样的题目.简言之,利用手段获得测试用例的第一行,输出结果.很显然利用wa, TLE, OLE等judge status可以获得测试用例.因此,果断Python写一个acm提交机器人.依赖lxml库.测试用例是The Ascii of H. #!/usr/env python import urllib2 import urllib import cookielib import logging from urlparse import * from time import sleep fro…
Number Sequence Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9058    Accepted Submission(s): 4149 Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[…
The kth great number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 8246    Accepted Submission(s): 3261 Problem Description Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round…
Number Sequence Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15017    Accepted Submission(s): 6585 Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b…
Problem Description Happy new year to everybody! Now, I want you to guess a minimum number x betwwn 1000 and 9999 to let (1) x % a = 0; (2) (x+1) % b = 0; (3) (x+2) % c = 0; and a, b, c are integers between 1 and 100. Given a,b,c, tell me what is the…
Problem Description Starting from point (0,0) on a plane, we have written all non-negative integers 0, 1, 2,- as shown in the figure. For example, 1, 2, and 3 has been written at points (1,1), (2,0), and (3, 1) respectively and this pattern has conti…
这道题,咋一看很像Fibonacci数列,使用递归或者改进的动态规划来解决.但是仔细一看,(1 <= n <= 100,000,000),使用这些方法,要么超时,要么肯定内存不够用,因此必须想别的办法.遇到这种情况也就只有找规律了.仔细看:f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7,因为存在取模运算,那么当n取到一定值后,f(n)肯定会重复出现.关于找规律的过程,博客园有一位朋友已经进行了详细分析了,请点击链接.下面给出最终的代码: #include&…
循环串的最小表示法. /* */ #include <iostream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <deque> #include <algorithm> #include <cstdio> #i…
快速矩阵幂,系数矩阵由多个二项分布组成.第1列是(0,(a+b)^k)第2列是(0,(a+b)^(k-1),0)第3列是(0,(a+b)^(k-2),0,0)以此类推. /* 3509 */ #include <iostream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector&g…
数学题,还是使用log避免大数,但是不要忘记需要+1,因为0也是1位,log(100)= 2,但却是3位. #include <stdio.h> #include <math.h> int main() { int case_n, n; int i; double sum; scanf("%d", &case_n); while (case_n--) { scanf("%d", &n); sum = 1.0f; ; i<…
数据量这么小,果断状态压缩+dp. /* 3006 */ #include <iostream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <deque> #include <algorithm> #include <c…
逆序数的性质.1. 暴力解 #include <stdio.h> #define MAXNUM 5005 int a[MAXNUM]; int main() { int n; int i, j, sum, min; while (scanf("%d", &n) != EOF) { ; i<n; ++i) scanf("%d", &a[i]); sum = ; ; i<n; ++i) { ; j<n; ++j) if (a…
DFS. /* 5179 */ #include <iostream> #include <algorithm> #include <map> #include <cstdio> #include <cstring> using namespace std; #define MAXN 1500 map<int, bool> tb; int a[MAXN], n, v; ][] = { {,}, {,,,}, {,,,,}, {,,,}…
Problem Description 有一天, KIKI 收到一张奇怪的信, 信上要KIKI 计算出给定数各个位上数字为偶数的和. eg. 5548 结果为12 , 等于 4 + 8 KIKI 很苦恼. 想请你帮忙解决这个问题. Input 输入数据有多组,每组占一行,只有一个数字,保证数字在INT范围内. Output 对于每组输入数据,输出一行,每两组数据之间有一个空行. Sample Input 415326 3262 Sample Output 12 10 简单题. 注意输出格式就行!…