HDU 5642 King's Order【数位dp】】的更多相关文章

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5642 King's Order  Accepts: 381  Submissions: 1361  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) 问题描述 国王演讲后士气大增,但此时战争还没有结束,国王时不时要下发命令. 由于国王的口吃并没有治愈,所以传令中可能出现:“让第三军-军…
Problem Description After the king's speech , everyone is encouraged. But the war is not over. The king needs to give orders from time to time. But sometimes he can not speak things well. So in his order there are some ones like this: "Let the group-…
题目链接: http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=677&pid=1003 题意: 求长度为n的序列中,每个字符(a~z)连续出现不超过3次的种数. 分析: 数位dp,设dp[i][j]表示进行到第i个字符,其中当前字符出现j次,然后每次状态转移一下就好了~ 代码: #include <cstdio> const int maxm = 2005, mod = 1e9+7; long long d…
King's Order 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5642 Description After the king's speech , everyone is encouraged. But the war is not over. The king needs to give orders from time to time. But sometimes he can not speak things well. So i…
题目链接: King's Order Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 101    Accepted Submission(s): 59 Problem Description After the king's speech , everyone is encouraged. But the war is not ove…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4507 题目大意:求指定范围内与7不沾边的所有数的平方和.结果要mod 10^9+7(鬼畜の元凶) 解题思路: 与7不沾边的数需要满足三个条件. ①不出现7 ②各位数和不是7的倍数 ③这个数不是7的倍数 这三个条件都是基础的数位DP. 但是这题要统计的不是符合条件个数,而是平方和. 也就是说在DP时候,要重建每个数,算出平方,然后求和. 需要维护三个值(推荐使用结构体), 假定dfs推出返回的结构体是…
K-wolf Number 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5787 Description Alice thinks an integer x is a K-wolf number, if every K adjacent digits in decimal representation of x is pairwised different. Given (L,R,K), please count how many K-wolf…
B-number Problem Description A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided by 13. For example, 130 and 2613 are wqb-numbers, but 143 and 2639 are not. Your task…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5787 [题目大意] 求区间[L,R]内十进制数相邻k位之间不相同的数字的个数. [题解] 很显然的数位dp,但是状态不知道该怎么转移,然后发现了递归数位DP这种神奇的姿势,每次记录前k位的数字,然后枚举下一位能用的数字,递归即可. [代码] #include <cstdio> #include <algorithm> #include <cstring> using n…
Valley Numer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 311    Accepted Submission(s): 165 Problem Description 众所周知,度度熊非常喜欢数字. 它最近发明了一种新的数字:Valley Number,像山谷一样的数字. 当一个数字,从左到右依次看过去数字没有出现先递增接…