钱币兑换问题
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 10832 Accepted Submission(s): 6582
Problem Description
在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。
Input
每行只有一个正整数N,N小于32768。
Output
对应每个输入,输出兑换方法数。
Sample Input
2934
12553
Sample Output
718831
13137761
Author
SmallBeer(CML)
Source
杭电ACM集训队训练赛(VII)
Recommend
lcy | We have carefully selected several similar problems for you: 1171 2159 1114 2191 2602
一道背包问题
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
long long int b[101010101];
int main()
{
int N;
memset(b, 0, sizeof(b));
b[0] = 1;
for(int i=1;i<=3;i++)
{
for(int j=i;j<=100203022;j++)
{
b[j] += b[j-i];
}
}
while(~scanf("%d", &N))
{
printf("%lld\n", b[N]);
}
return 0;
}