输入1个数N,N = 100表示1元钱。(1 <= N <= 100000)Output输出Mod 10^9 + 7的结果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;}
新闻热点
疑难解答