輸入1個(gè)數(shù)N,N = 100表示1元錢(qián)。(1 <= N <= 100000)Output輸出Mod 10^9 + 7的結(jié)果Input示例5Output示例4思路:
背包水題。代碼:
#include <bits/stdc++.h>using namespace std;typedef long long ll;const int MAXN = 1e5 + 10;const int MOD = 1e9 + 7;int v[20] = {0, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000};ll dp[MAXN];int main() { int n; scanf("%d", &n); dp[0] = 1; for (int i = 1; i <= 13; i++) { for (int j = v[i]; j <= n; j++) { dp[j] = (dp[j] + dp[j - v[i]]) % MOD; } } PRintf("%I64d/n", dp[n]); return 0;}
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注