标签:
#include<set> #include<map> #include<queue> #include<stack> #include<cmath> #include<string> #include<vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define INF 1000000001 #define MOD 1000000007 #define ll long long #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define pi acos(-1.0) using namespace std; const int MAXN = 300; int c[MAXN][105],tp[MAXN][105],n,val[6]; int main() { val[1] = 1,val[2] = 5,val[3] = 10,val[4] = 25,val[5] = 50; while(~scanf("%d",&n)){ if(!n){ puts("1"); continue; } memset(c,0,sizeof(c)); memset(tp,0,sizeof(tp)); for(int i = 0; i <= min(n,100); i++){ c[i][i] = 1; } for(int i = 2; i <= 5; i++){ for(int j = 0; j <= n; j++){ for(int k = 0; k + j <= n; k += val[i]){ for(int l = 0; l + k / val[i] <= 100; l ++){ tp[j + k][l + k / val[i]] += c[j][l]; } } } for(int j = 0; j <= n; j++){ for(int k = 0; k <= 100; k++){ c[j][k] = tp[j][k]; tp[j][k] = 0; } } } int ans = 0; for(int i = 1; i <= 100; i++){ ans += c[n][i]; } cout<<ans<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/sweat123/p/5515414.html