PlanttPastes

euler 31

Jun 25th, 2026
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. constexpr int coins[] = {1, 2, 5, 10, 20, 50, 100, 200};
  5. int dp[201][8];
  6.  
  7. signed main() {
  8.     ios::sync_with_stdio(0);
  9.     cin.tie(0); cout.tie(0);
  10.     dp[0][0] = 1;
  11.     for (int i = 0; i <= 200; i++) {
  12.         for (int j = 0; j < 8; j++) {
  13.             if (j < 7) dp[i][j + 1] += dp[i][j];
  14.             if (i + coins[j] < 201) dp[i + coins[j]][j] += dp[i][j];
  15.         }
  16.     }
  17.     cout << dp[200][7];
  18. }
Advertisement
Add Comment
Please, Sign In to add comment