結果

問題 No.612 Move on grid
ユーザー finefine
提出日時 2017-12-16 02:10:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,500 ms
コード長 1,087 bytes
コンパイル時間 1,505 ms
コンパイル使用メモリ 166,368 KB
実行使用メモリ 44,576 KB
最終ジャッジ日時 2023-08-22 22:19:16
合計ジャッジ時間 3,494 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 9 ms
5,204 KB
testcase_04 AC 59 ms
44,548 KB
testcase_05 AC 116 ms
44,576 KB
testcase_06 AC 109 ms
44,500 KB
testcase_07 AC 57 ms
44,556 KB
testcase_08 AC 109 ms
44,528 KB
testcase_09 AC 58 ms
22,972 KB
testcase_10 AC 42 ms
17,680 KB
testcase_11 AC 14 ms
7,152 KB
testcase_12 AC 64 ms
26,792 KB
testcase_13 AC 25 ms
11,056 KB
testcase_14 AC 84 ms
34,440 KB
testcase_15 AC 15 ms
7,668 KB
testcase_16 AC 97 ms
39,800 KB
testcase_17 AC 20 ms
11,324 KB
testcase_18 AC 79 ms
32,824 KB
testcase_19 AC 38 ms
20,460 KB
testcase_20 AC 55 ms
28,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll dp[505][20005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t, a, b, c, d, e;
    cin >> t >> a >> b >> c >> d >> e;
    int geta = 10000;
    dp[0][geta] = 1;
    for (int i = 0; i < t; i++) {
        for (int j = -10000; j <= 10000; j++) {
            if (dp[i][j + geta] == 0) continue;
            if (j + a <= 10000) (dp[i + 1][j + a + geta] += dp[i][j + geta]) %= MOD;
            if (j - a >= -10000) (dp[i + 1][j - a + geta] += dp[i][j + geta]) %= MOD;
            if (j + b <= 10000) (dp[i + 1][j + b + geta] += dp[i][j + geta]) %= MOD;
            if (j - b >= -10000) (dp[i + 1][j - b + geta] += dp[i][j + geta]) %= MOD;
            if (j + c <= 10000) (dp[i + 1][j + c + geta] += dp[i][j + geta]) %= MOD;
            if (j - c >= -10000) (dp[i + 1][j - c + geta] += dp[i][j + geta]) %= MOD;
        }
    }

    ll ans = 0;
    for (int i = d; i <= e; i++) {
        (ans += dp[t][i + geta]) %= MOD;
    }
    cout << ans << endl;
    return 0;
}
0