結果
| 問題 | No.612 Move on grid | 
| コンテスト | |
| ユーザー |  pin | 
| 提出日時 | 2017-12-13 10:09:44 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 227 ms / 2,500 ms | 
| コード長 | 889 bytes | 
| コンパイル時間 | 699 ms | 
| コンパイル使用メモリ | 82,528 KB | 
| 実行使用メモリ | 81,728 KB | 
| 最終ジャッジ日時 | 2024-12-18 00:52:52 | 
| 合計ジャッジ時間 | 3,215 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 17 | 
ソースコード
#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;
}
            
            
            
        