题目链接
继续水过。。。
1 #include <stdio.h> 2 #include <string.h> 3 #define N 30010 4 #define eps 0.00000001 5 long long p1[N],p2[N]; 6 int main() 7 { 8 int a[6] = {1,5,10,25,50}; 9 int i,j,k,n; 10 p1[0] = 1; 11 for(i = 0; i <= 4; i ++) 12 { 13 for(j = 0; j <= 30000; j ++) 14 { 15 for(k = 0;; k += a[i]) 16 { 17 if(k+j > 30000) break; 18 p2[k+j] += p1[j]; 19 } 20 } 21 for(j = 0; j <= N; j ++) 22 { 23 p1[j] = p2[j]; 24 p2[j] = 0; 25 } 26 } 27 while(scanf("%d",&n)!=EOF) 28 { 29 if(p1[n] == 1) 30 printf("There is only %lld way to produce %d cents change.\n",p1[n],n); 31 else 32 printf("There are %lld ways to produce %d cents change.\n",p1[n],n); 33 } 34 return 0; 35 }