結果

問題 No.612 Move on grid
ユーザー nxterunxteru
提出日時 2018-06-19 22:52:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,500 ms
コード長 762 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 69,948 KB
実行使用メモリ 44,496 KB
最終ジャッジ日時 2023-09-13 07:15:07
合計ジャッジ時間 2,310 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 7 ms
5,216 KB
testcase_04 AC 54 ms
44,420 KB
testcase_05 AC 102 ms
44,372 KB
testcase_06 AC 95 ms
44,416 KB
testcase_07 AC 54 ms
44,496 KB
testcase_08 AC 95 ms
44,376 KB
testcase_09 AC 48 ms
22,964 KB
testcase_10 AC 35 ms
17,592 KB
testcase_11 AC 11 ms
7,040 KB
testcase_12 AC 54 ms
26,516 KB
testcase_13 AC 21 ms
11,052 KB
testcase_14 AC 71 ms
34,344 KB
testcase_15 AC 13 ms
7,660 KB
testcase_16 AC 84 ms
39,680 KB
testcase_17 AC 17 ms
11,300 KB
testcase_18 AC 67 ms
32,588 KB
testcase_19 AC 33 ms
20,212 KB
testcase_20 AC 47 ms
28,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define M 1000000007
ll t,a,b,c,d,e,ans;
ll dp[505][20005];
int main(void){
    cin>>t>>a>>b>>c>>d>>e;
    dp[0][10000]=1;
    for(int i=0;i<t;i++){
        for(int j=0;j<=20000;j++){
            if(dp[i][j]>0){
                dp[i+1][j+a]=(dp[i+1][j+a]+dp[i][j])%M;
                dp[i+1][j-a]=(dp[i+1][j-a]+dp[i][j])%M;
                dp[i+1][j+b]=(dp[i+1][j+b]+dp[i][j])%M;
                dp[i+1][j-b]=(dp[i+1][j-b]+dp[i][j])%M;
                dp[i+1][j+c]=(dp[i+1][j+c]+dp[i][j])%M;
                dp[i+1][j-c]=(dp[i+1][j-c]+dp[i][j])%M;
            }
        }
    }
    for(int i=d+10000;i<=e+10000;i++)ans=(ans+dp[t][i])%M;
    cout<<ans<<endl;
}
0