• Source
    1. #include<bits/stdc++.h>
    2.  
    3. using namespace std;
    4. long long nways[30005];
    5.  
    6. int coins[7]={1,5,10,25,50};
    7.  
    8. void init()
    9. {
    10. for(int i=0;i<5;i++)
    11. {
    12. for(int j=coins[i],k=0;j<=30005;j++,k++)
    13. {
    14. nways[j]+=nways[k];
    15. }
    16. }
    17. }
    18. int main()
    19. {
    20. long long cents;
    21. nways[0]=1;
    22. init();
    23. while(scanf("%lld",&cents)==1)
    24. {
    25. if(nways[cents]==1)
    26. {
    27. printf("There is only 1 way to produce %lld cents change.\n",cents);
    28. }
    29. else if(nways[cents]>1)
    30. {
    31. printf("There are %lld ways to produce %lld cents change.\n",nways[cents],cents);
    32. }
    33. }
    34. return 0;
    35. }
    36.