結果

問題 No.612 Move on grid
ユーザー pinpin
提出日時 2017-12-13 10:09:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 296 ms / 2,500 ms
コード長 889 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 81,768 KB
実行使用メモリ 81,808 KB
最終ジャッジ日時 2023-08-22 22:17:18
合計ジャッジ時間 3,646 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,428 KB
testcase_03 AC 13 ms
23,792 KB
testcase_04 AC 49 ms
81,672 KB
testcase_05 AC 252 ms
81,676 KB
testcase_06 AC 296 ms
81,620 KB
testcase_07 AC 35 ms
81,808 KB
testcase_08 AC 291 ms
81,676 KB
testcase_09 AC 108 ms
81,728 KB
testcase_10 AC 88 ms
52,656 KB
testcase_11 AC 24 ms
27,920 KB
testcase_12 AC 138 ms
63,000 KB
testcase_13 AC 45 ms
38,136 KB
testcase_14 AC 190 ms
72,964 KB
testcase_15 AC 26 ms
29,968 KB
testcase_16 AC 187 ms
81,256 KB
testcase_17 AC 32 ms
38,308 KB
testcase_18 AC 152 ms
72,988 KB
testcase_19 AC 61 ms
58,596 KB
testcase_20 AC 85 ms
79,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int T, d, e;
int num[6];
ll dp[505][20005];

ll rec(int t, int k){
    if (dp[t][k] >= 0) return dp[t][k];
    if (t == T){
        if (d + 10000 <= k && k <= e + 10000) return dp[t][k] = 1;
        else return dp[t][k] = 0;
    }

    ll ret = 0;
    for (int i = 0; i < 6; i++){
        ret += rec(t + 1, k + num[i]);
        ret %= MOD;
    }

    return dp[t][k] = ret;
}
int main(void){
    cin >> T >> num[0] >> num[1] >> num[2] >> d >> e;
    for (int i = 0; i < 3; i++) num[i + 3] = -num[i];

    for (int i = 0; i <= T; i++)
        for (int j = 0; j <= 20000; j++) dp[i][j] = -1;
    
    cout << rec(0, 10000) << endl;
}
0