結果
問題 | No.695 square1001 and Permutation 4 |
ユーザー | square1001 |
提出日時 | 2018-05-13 10:32:55 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 974 bytes |
コンパイル時間 | 771 ms |
コンパイル使用メモリ | 65,164 KB |
実行使用メモリ | 42,384 KB |
最終ジャッジ日時 | 2023-09-30 01:16:49 |
合計ジャッジ時間 | 5,990 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 19 ms
5,392 KB |
testcase_02 | AC | 20 ms
13,616 KB |
testcase_03 | AC | 19 ms
13,504 KB |
testcase_04 | AC | 73 ms
13,784 KB |
testcase_05 | RE | - |
testcase_06 | AC | 161 ms
23,856 KB |
testcase_07 | AC | 142 ms
23,732 KB |
testcase_08 | RE | - |
testcase_09 | AC | 581 ms
23,740 KB |
testcase_10 | AC | 35 ms
7,460 KB |
testcase_11 | AC | 1,156 ms
42,320 KB |
testcase_12 | RE | - |
testcase_13 | AC | 377 ms
42,384 KB |
ソースコード
#include <iostream> using namespace std; int n, m, x[7], dp[10000009]; int solve(int mod) { dp[0] = 1; for (int i = 1; 2 * i - 2 < n; i++) { dp[i] = 0; for (int j = 0; j < m; j++) { if (i >= x[j]) { dp[i] += dp[i - x[j]]; if (dp[i] >= mod) dp[i] -= mod; } } } int ret = 0; for (int i = 0; i < m; i++) { for (int j = 0; 2 * j < n; j++) { if (2 * (j + x[i]) >= n) { ret = (ret + 1LL * dp[j] * dp[n - j - x[i] - 1]) % mod; } } } return ret; } int binpow(int a, int b, int mod) { int ret = 1; while (b) { if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1; } return ret; } int main() { cin >> n >> m; for (int i = 0; i < m; i++) cin >> x[i]; int part1 = 168647939; int part2 = 592951213; int res1 = solve(part1); int res2 = solve(part2); int subans = 1LL * (res2 - res1 + part2) * binpow(part1, part2 - 2, part2) % part2; long long ans = 1LL * subans * part1 + res1; cout << ans << '\n'; return 0; }