Advertisement
juanjo12x

UVA_357_Ways_WA

Apr 10th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char** argv) {
  4.     int n;
  5.     int coins[] = {1,5,10,25,50};
  6.     unsigned long long int  ways[30005];int i;int j;
  7.     ways[0]=1;int coin;
  8.         for (i=0;i<5;i++){
  9.            
  10.             coin = coins[i];
  11.             for(j=coin;j<30005;j++){
  12.                
  13.                 ways[j]=ways[j]+ways[j-coin];    
  14.                 }
  15.                                
  16.             }
  17.        
  18.     while(scanf("%d",&n)==1){
  19.        
  20.         if (ways[n]>1){
  21.             printf("There are %llu ways to produce %d cents change.\n",ways[n],n);
  22.         }else{
  23.             printf("There is only 1 way to produce %d cents change.\n",n);
  24.         }
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement