URAL 1233 - Amusing Numbers】的更多相关文章

参照了nocow上的解法,照搬过来…… 易知一个数X在数列中在另一个数Y前,当且仅当X前缀小于Y或前缀相等X短,那么我们分布考虑,比如对于数48561: 5位上:10000~48560; 4位上:1000~4856; 3位上:100~485; 2位上:10~48; 1位上:1~4. 这样我们就得到了1..N中4856的位置,可以用这个来判错. 接下来的方法类似,为了使得我们的N满足要求,我们必须去找比48561大且前缀比其小的数,同样有: 6位上:100000~48569;  //注意红色部分比…
首先计算出k至少为第几位,如果m小于这个数,那么输出0 还有一种情况, 就是10的i次方的这种情况,如果i+1等于m,那么直接输出k,否则输出0 其他的情况,就是二分,然后判断计算其插入到k之前的数的个数与k至少的位数之和 #include <stdio.h> #include <math.h> #define LL unsigned long long LL d[20],k,m,s; int t; void init() { d[0]=1; for(int i=1;i<20…
题目传送门 /* 题意:n位数字,任意连续的三位数字组成的数字是素数,这样的n位数有多少个 最优子结构:考虑3位数的数字,可以枚举出来,第4位是和第3位,第2位组成的数字判断是否是素数 所以,dp[i][j][k] 表示i位数字,最高位数字j,第二高位数字k 状态转移方程:dp[i][j][k] += dp[i-1][k][l] 注意:最高位从1开始枚举:) 详细解释:http://blog.csdn.net/zhangyanxing666/article/details/9628563 */…
题目传送门 题意:n位数,k进制,求个数分析:dp[i][j] 表示i位数,当前数字为j的个数:若j==0,不加dp[i-1][0]; 代码1: #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> using namespace std; const int MAXN = 22; const int INF = 0x3f3f3f3f; long long…
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate integers together in their spare time. Nikolay thinks an integer is interesting if it is a prime number. However, Asya thinks an integer is interesting i…
1150. Page Numbers Time limit: 1.0 secondMemory limit: 64 MB John Smith has decided to number the pages in his notebook from 1 to N. Please, figure out the number of zeros, ones, twos, …, nines he might need. Input One number N (1 ≤ N < 109). Output…
2031. Overturned Numbers Time limit: 1.0 second Memory limit: 64 MB Little Pierre was surfing the Internet and came across an interesting puzzle: What is the number under the car? It took some time before Pierre solved the puzzle, but eventually he u…
In the present world you frequently meet a lot of call numbers and they are going to be longer and longer. You need to remember such a kind of numbers. One method to do it in an easy way is to assign letters to digits as shown in the following pictur…
题目链接 题意 :与1009一样,不过这个题的数据范围变大. 思路:因为数据范围变大,所以要用大数模拟,用java也行,大数模拟也没什么不过变成二维再做就行了呗.当然也可以先把所有的都进行打表,不过要用三维了就 . //URAL 1012 #include <stdio.h> #include <string.h> #include <iostream> using namespace std ; ]; ][] ; int main() { int n, k ; sca…
1118. Nontrivial Numbers Time limit: 2.0 secondMemory limit: 64 MB Specialists of SKB Kontur have developed a unique cryptographic algorithm for needs of information protection while transmitting data over the Internet. The main advantage of the algo…