DuongNhi99

B - Dollars (1-12)

Nov 30th, 2020 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int coin[12] = {0, 1, 2, 4, 10, 20, 40, 100, 200, 400, 1000, 2000}; //Mã hóa (chia số tiền cho 5)
  5. long long dp[6005];
  6.  
  7. int main(){
  8.  
  9.     //freopen("in.txt", "r", stdin);
  10.     //freopen("B-Dollars.inp", "r", stdin);
  11.     //freopen("B-Dollars.out", "w", stdout);
  12.     ios_base::sync_with_stdio(false);
  13.     cin.tie(NULL); cout.tie(NULL);
  14.  
  15.     dp[0] = 1;
  16.     for(int i = 1; i <= 11; i++)
  17.         for(int j = coin[i]; j <= 6000; j++)
  18.             dp[j] += dp[j-coin[i]];
  19.  
  20.     double n;
  21.     while(cin >> n) {
  22.         if(n == 0.00) break;
  23.  
  24.         int m = int(n * 20);
  25.  
  26.         cout << setiosflags(ios::right) << setw(6) << setprecision(2) << fixed << n;
  27.         cout << setiosflags(ios::right) << setw(17) << dp[m] << '\n';
  28.     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment