codeforces628D. Magic Numbers (数位dp)】的更多相关文章

Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the number on even positions and nowhere else. For example, the numbers 1727374, 17, 1 are 7-magic but 77, 7, 123, 34, 71 are n…
D. Magic Numbers 题目连接: http://www.codeforces.com/contest/628/problem/D Description Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the number on even positions and nowhere els…
Magic Numbers 题意: 题意比较难读:首先对于一个串来说, 如果他是d-串, 那么他的第偶数个字符都是是d,第奇数个字符都不是d. 然后求[L, R]里面的多少个数是d-串,且是m的倍数. 题解: 数位dp. dp[x][y]代表的是余数为x, 然后剩下的长度是y的情况的方案数是多少. 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","r&…
[CF628D]Magic Numbers 题意:求[a,b]中,偶数位的数字都是d,其余为数字都不是d,且能被m整除的数的个数(这里的偶数位是的是从高位往低位数的偶数位).$a,b<10^{2000},m \le 2000 ,0 \le d \le 9$ 题解:用f[i][j]表示有i+1位,第i位是d,且%m=j的数的个数.(这个状态可能有点奇怪,不过比较便于转移)然后转移方式还是惯用的方法,判一下如果原数的偶数位不是d或者奇数位是d则停止计算即可. 对了,题意有bug.题里说个位数的偶数位…
题意:找到[a, b]符合下列要求的数的个数. 1.该数字能被m整除 2.该数字奇数位全不为d,偶数位全为d 分析: 1.dp[当前的位数][截止到当前位所形成的数对m取余的结果][当前数位上的数字是否到达了上限] 2.对于第三维的上限,例如一个数字是54362,那么如果前四位是5436,那么前四位都到达了上限,第五位可以从0枚举所有可能,例如如果第五位是1,那么就没到达上限,如果是6就到达了上限,简而言之,就是个匹配的问题. 需要注意的是,上限不是指第二位数字只能是0~4,第三位数字只能是0~…
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP) 链接:https://ac.nowcoder.com/acm/contest/163/J?&headNav=acm来源:牛客网 时间限制:C/C++ 8秒,其他语言16秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 NIBGNAUK is an odd boy and his taste is strange a…
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if…
D. Beautiful numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem/D Description Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only i…
Description The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, Paper, Stone' (also known as 'Rock, Paper, Scissors', 'Ro, Sham, Bo', and a host of other names) in order to make arbitrary decisions such as who gets…
题目链接:uva 10712 - Count the Numbers 题目大意:给出n,a.b.问说在a到b之间有多少个n. 解题思路:数位dp.dp[i][j][x][y]表示第i位为j的时候.x是否前面是相等的.y是否已经出现过n.对于n=0的情况要特殊处理前导0,写的很乱.搓死. #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using nam…