GastonFontenla

UVa: 147 - Dollars

May 29th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. long long m[11][30001];
  8. int a[11] = {5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000};
  9.  
  10. int main()
  11. {
  12.     for(int i=0; i<11; i++)
  13.         m[i][0] = 1;
  14.     for(int i=1; i<30001; i++)
  15.         m[0][i] = 1;
  16.  
  17.     for(int i=1; i<11; i++)
  18.     {
  19.         for(int j=0; j<30001; j++)
  20.         {
  21.             if(j >= a[i])
  22.                 m[i][j] = m[i-1][j] + m[i][j-a[i]];
  23.             else
  24.                 m[i][j] = m[i-1][j];
  25.         }
  26.     }
  27.  
  28.     float n;
  29.     scanf("%f", &n);
  30.     while(n != 0.00)
  31.     {
  32.         int k = (int) round(n * 100);
  33.         printf("%6.2f%17lld\n", n, m[10][k]);
  34.         scanf("%f", &n);
  35.     }
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment