标签:
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
__int64 flag;
int num[] = {50, 25, 10, 5, 1};
void dfs(int n, int deep, int last, int coin)
{
if(n<0 || coin>100 ) return;
if(n==0 && coin <=100)
{flag++; return;}
for(int i=deep; i<5; i++)
{
if(num[i] <= last)
{
last = num[i];
coin++;
dfs(n-num[i], deep, last, coin);
coin--;
}
}
}
int result[300];
int main()
{
int n;
//while( scanf("%d", &n)!=EOF)
for(n=0; n<=250; n++)
{
flag = 0;
//if(n==0) {printf("0\n"); continue;}
if(n >= 50) dfs(n, 0, num[0], 0);
else if(n>=25) dfs(n, 1, num[1], 0);
else if(n>=10) dfs(n, 2, num[2], 0);
else if(n>=5) dfs(n, 3, num[3], 0);
else dfs(n,4, num[4], 0);
printf("%I64d\n", flag);
//result[n] = flag;
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/sober-reflection/p/3306aa8e5d2f6ac1f0a0343248ef3377.html