結果
問題 | No.3046 yukicoderの過去問 |
ユーザー | fine |
提出日時 | 2019-04-01 21:39:19 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 677 bytes |
コンパイル時間 | 1,721 ms |
コンパイル使用メモリ | 169,676 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-05-05 04:12:17 |
合計ジャッジ時間 | 5,102 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,624 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 4 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 3 ms
5,376 KB |
testcase_06 | TLE | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1000000007; ll modpow(ll x, ll n, ll mod = MOD) { ll res = 1; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); int K, n; cin >> K >> n; vector<int> x(n); for (int i = 0; i < n; i++) cin >> x[i]; vector<ll> dp(K + 1, 0); dp[0] = 1; for (int i = 1; i <= K; i++) { for (int y : x) { if (i < y) break; (dp[i] += dp[i - y]) %= MOD; } } cout << dp[K] << endl; return 0; }