結果
問題 | No.612 Move on grid |
ユーザー | pekempey |
提出日時 | 2017-12-12 00:05:43 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 147 ms / 2,500 ms |
コード長 | 776 bytes |
コンパイル時間 | 571 ms |
コンパイル使用メモリ | 70,980 KB |
実行使用メモリ | 87,584 KB |
最終ジャッジ日時 | 2023-08-22 22:10:47 |
合計ジャッジ時間 | 3,328 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 4 ms
4,376 KB |
testcase_03 | AC | 36 ms
23,428 KB |
testcase_04 | AC | 147 ms
87,292 KB |
testcase_05 | AC | 136 ms
87,332 KB |
testcase_06 | AC | 134 ms
87,332 KB |
testcase_07 | AC | 145 ms
87,584 KB |
testcase_08 | AC | 134 ms
87,288 KB |
testcase_09 | AC | 134 ms
87,488 KB |
testcase_10 | AC | 84 ms
55,808 KB |
testcase_11 | AC | 41 ms
28,324 KB |
testcase_12 | AC | 99 ms
65,844 KB |
testcase_13 | AC | 56 ms
38,528 KB |
testcase_14 | AC | 115 ms
76,180 KB |
testcase_15 | AC | 44 ms
29,660 KB |
testcase_16 | AC | 132 ms
86,412 KB |
testcase_17 | AC | 59 ms
39,908 KB |
testcase_18 | AC | 118 ms
77,588 KB |
testcase_19 | AC | 91 ms
61,020 KB |
testcase_20 | AC | 129 ms
82,720 KB |
ソースコード
#include <iostream> #include <algorithm> #include <vector> using namespace std; // 20 * 500 * 2 const long long mod = 1e9 + 7; long long dp[501][22020]; void to(long long &x, long long y) { x += y; if (x >= mod) x -= mod; } int main() { int n; cin >> n; int a, b, c, d, e; cin >> a >> b >> c >> d >> e; dp[0][10200] = 1; for (int i = 0; i < n; i++) { for (int j = 50; j < 21000; j++) { to(dp[i + 1][j + a], dp[i][j]); to(dp[i + 1][j - a], dp[i][j]); to(dp[i + 1][j + b], dp[i][j]); to(dp[i + 1][j - b], dp[i][j]); to(dp[i + 1][j + c], dp[i][j]); to(dp[i + 1][j - c], dp[i][j]); } } long long ans = 0; for (int i = 10200 + d; i <= 10200 + e; i++) { to(ans, dp[n][i]); } cout << ans << endl; }