結果
| 問題 | No.612 Move on grid | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-12-15 16:41:40 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 101 ms / 2,500 ms | 
| コード長 | 755 bytes | 
| コンパイル時間 | 593 ms | 
| コンパイル使用メモリ | 70,784 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-02 18:16:29 | 
| 合計ジャッジ時間 | 2,829 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 17 | 
ソースコード
#include<iostream>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define inRange(x,a,b) (a <= x && x < b)
int main(){
    int t, a[3], d, e;
    cin >> t >> a[0] >> a[1] >> a[2] >> d >> e;
    vector<int> dp(20001, 0);
    dp[10000] = 1;
    while(t-- > 0){
        vector<int> ndp(20001, 0);
        for(int i = 0; i < 3; i++){
            for(int j : {-1, 1}){
                for(int k = 0; k <= 20000; k++){
                    if(inRange(k+j*a[i], 0, 20001)){
                        (ndp[k+j*a[i]] += dp[k]) %= mod;
                    }
                }
            }
        }
        dp = ndp;
    }
    int ans = 0;
    for(int i = d+10000; i <= e+10000; i++) (ans += dp[i]) %= mod;
    cout << ans << endl;
    return 0;
}
            
            
            
        