ural 1353. Milliard Vasya's Function
2015-01-29 08:12
375 查看
题目看不懂,,,
简直了
其实开始都是废话,重要的就一句
Vasya’s Functions (VF) are rather simple: the value of the Nth VF
in the point S is an amount of integers from
1 to N that have the sum of digits S.
就是求1到N中各位数字之和为S的数的个数
只想看题意的童鞋现在可以ctrl+w了
---------------下面是思路的分界线-------------
就是一个简单的dp
可以由N的位数来划分状态
以下是状态转移方程
dp[i][j]+=dp[i-k][j-1];
其中j是N的位数,i是N的各位数之和,k的取值是0~9
dp[s][9]即为所求
(好像没什么好说的了。。还是直接上代码吧
(哦对了,题中给的N是10^9 所以dp[1][9]要+1 (想一想,为什么
简直了
其实开始都是废话,重要的就一句
Vasya’s Functions (VF) are rather simple: the value of the Nth VF
in the point S is an amount of integers from
1 to N that have the sum of digits S.
就是求1到N中各位数字之和为S的数的个数
只想看题意的童鞋现在可以ctrl+w了
---------------下面是思路的分界线-------------
就是一个简单的dp
可以由N的位数来划分状态
以下是状态转移方程
dp[i][j]+=dp[i-k][j-1];
其中j是N的位数,i是N的各位数之和,k的取值是0~9
dp[s][9]即为所求
(好像没什么好说的了。。还是直接上代码吧
(哦对了,题中给的N是10^9 所以dp[1][9]要+1 (想一想,为什么
#include<cstdio> #include<cstring> using namespace std; int dp[100][11]; int main(){ int s; memset(dp,0,sizeof(dp)); dp[0][0]=1; for(int j=1;j<=9;j++) for(int k=0;k<=9;k++) for(int i=k;i<=81;i++) dp[i][j]+=dp[i-k][j-1]; dp[1][9]++; while(~scanf("%d",&s)){ printf("%d\n",dp[s][9]); } return 0; }
相关文章推荐
- URAL 1353. Milliard Vasya's Function(dp)
- Ural 1353 Milliard Vasya's Function(DP)
- URAL 1353 Milliard Vasya's Function(DP)
- URAL 1353 Milliard Vasya's Function(DP)
- URAL1353---Milliard Vasya's Function(简单数位dp)
- Ural 1353. Milliard Vasya's Function 暴搜
- Ural1353-Milliard Vasya's Function
- Milliard Vasya's Function(Ural_1353)
- ural 1353. Milliard Vasya's Function
- Timus 1353. Milliard Vasya's Function
- ural 1353. Milliard Vasya's Function
- ural 1353. Milliard Vasya's Function(dp)
- Ural 1353 Milliard Vasya's Function(DP)
- ural 1993 This cheeseburger you don't need
- Codeforces #319(Div.2) C. Vasya and Petya's Game(数学题)
- Ural 1671. Anansi's Cobweb
- Ural 1671 Anansi's Cobweb
- Milliard Vasya's Function-Ural1353动态规划
- URAL 1800 Murphy's Law(物理判断题)
- ACM k进制高精度优化 URAL 1803 The Czechs' Rifles 滚动数组