Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
2603 | 孙浚轩 | 统计硬币 | C++ | Wrong Answer | 9 MS | 12044 KB | 713 | 2024-01-14 17:54:17 |
#include <iostream> #include <vector> using namespace std; int countCombinations(int n, int m) { vector<int> coins = {1, 2, 5}; vector<vector<int>> dp(n+1, vector<int>(m+1, 0)); dp[0][0] = 1; for (int i = 0; i <= n; i++) { dp[i][0] = 1; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { dp[i][j] = dp[i-1][j]; if (j >= coins[i-1]) { dp[i][j] += dp[i][j-coins[i-1]]; } } } return dp[n][m]; } int main() { int T; cin >> T; while (T--) { int n, m; cin >> n >> m; cout << countCombinations(n, m) << endl; } return 0; }
------Input------
20 5 10 8 20 3 6 2 4 10 26 11 27 1 1 1 2 2 2 1 5 5 25 100 250 1000 3000 26 120 9 30 12 27 7 25 27 54 32 100 4 13
------Answer-----
2 2 1 1 3 3 1 1 1 1 1 21 167 1 2 3 1 7 6 1
------Your output-----
40 464 5 3 2880 6144 1 1 2 1 168 0 0 806354944 928 12288 336 1409286144 1946157056 28