HDU 4389 X mod f(x)】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=4389 题意 为[A,B] 区间内的数能刚好被其位数和整除的数有多少个. 分析 典型的数位dp...比赛时想不出状态怎么构造,太弱了我. 言归正传,数位和有81种状态,怎么判断当前数字是否被整除呢?可以利用余数的思想,至此,定义状态dp[pos][sum][mod][res]表示前pos位的数位和为sum模mod的结果为res的个数,采用记忆化搜索比较简洁. #include<iostream> #inclu…
X mod f(x) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Here is a function f(x): int f ( int x ) {     if ( x == 0 ) return 0;     return f ( x / 10 ) + x % 10; } Now, you want to know, in a …
思路: 每次枚举数字和也就是取模的f(x),这样方便计算. 其他就是基本的数位Dp了. 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vector> #define ll __int64 #define pi acos(-1…
题意:求[A,B]内有多少个数,满足x % f(x) == 0. 解法:数位DP.转化为ans = solve(b) - solve(a - 1).设dp[i][sum][mod][r]表示长度为i,各位和为sum,模mod余r的数的个数. 当在数字后面新添加一位j时,则有dp[i + 1][sum + j][mod][(r * 10 + j) % mod] += dp[i][sum][mod][r]. 当一个数比n小时,一定是因为从某一位开始出现了当前位的数字比n当前位数字小的情况,从高到低枚…
数位DP........ X mod f(x) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1403    Accepted Submission(s): 599 Problem Description Here is a function f(x): int f ( int x ) { if ( x == 0 ) return 0;…
X mod f(x) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2792    Accepted Submission(s): 1101 Problem Description Here is a function f(x): int f ( int x ) { if ( x == 0 ) return 0; return f (…
Problem Description Here is a function f(x): int f ( int x ) { if ( x == 0 ) return 0; return f ( x / 10 ) + x % 10; } Now, you want to know, in a given interval [A, B] (1 <= A <= B <= 10 9), how many integer x that mod f(x) equal to 0.   Input T…
Naive Operations Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 502768/502768 K (Java/Others)Total Submission(s): 2691    Accepted Submission(s): 1183 Problem Description In a galaxy far, far away, there are two integer sequence a and b of l…
Remainder Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3036    Accepted Submission(s): 679 Problem Description Coco is a clever boy, who is good at mathematics. However, he is puzzled by a d…
求区间内满足x%fx==0的数的个数,fx为该数各个位数上的数字之和Sample Input21 1011 20 Sample OutputCase 1: 10Case 2: 3 大小不是你想开,想开就能开,汗颜-_-! #include<cstdio> #include<cstring> using namespace std; ][][][]; ]; int dfs(int p,int mod,int s,int m,bool e) { //位置,模数,前面之和,当前位数%mo…