problem=1068">http://www.lightoj.com/volume_showproblem.php?problem=1068 求出区间[A,B]内能被K整除且各位数字之和也能被K整除的数的个数.(1 ≤ A ≤ B < 231 and 0 < K < 10000) 算是最简单的数位dp了.k在这里是10000.三维数组都开不开.可是想想会发现A,B最多有10位,各位数字之和不会超过90.那么当 k >= 90时,就不用dp,由于个位数字之和对k取…
An integer is divisible by 3 if the sum of its digits is also divisible by 3. For example, 3702 is divisible by 3 and 12 (3+7+0+2) is also divisible by 3. This property also holds for the integer 9. In this problem, we will investigate this property…
数位DP #include <cstdio> #include <cstring> using namespace std; ; ; long long n; int f[MAX_DIGIT]; ][MAX_DIGIT * ]; int k; int to_digits(long long a) { ; ) { f[ret++] = a % ; a /= ; } return ret; } long long dfs(int digit, bool less, int sum, i…
题目链接 http://lightoj.com/volume_showproblem.php?problem=1031 Description You are playing a two player game. Initially there are n integer numbers in an array and player A and B get chance to take them alternatively. Each player can take one or more nu…
http://www.lightoj.com/volume_showproblem.php?problem=1005 PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB A rook is a piece used in the game of chess which is played on a board of square grids. A rook can only move…