結果

問題 No.612 Move on grid
ユーザー kotatsugamekotatsugame
提出日時 2020-03-11 06:23:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 659 ms / 2,500 ms
コード長 604 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 66,828 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 19:03:54
合計ジャッジ時間 9,056 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 6 ms
6,944 KB
testcase_02 AC 10 ms
6,944 KB
testcase_03 AC 144 ms
6,940 KB
testcase_04 AC 659 ms
6,944 KB
testcase_05 AC 557 ms
6,940 KB
testcase_06 AC 546 ms
6,940 KB
testcase_07 AC 543 ms
6,940 KB
testcase_08 AC 582 ms
6,948 KB
testcase_09 AC 585 ms
6,940 KB
testcase_10 AC 358 ms
6,944 KB
testcase_11 AC 161 ms
6,944 KB
testcase_12 AC 412 ms
6,944 KB
testcase_13 AC 227 ms
6,940 KB
testcase_14 AC 462 ms
6,944 KB
testcase_15 AC 168 ms
6,940 KB
testcase_16 AC 547 ms
6,940 KB
testcase_17 AC 239 ms
6,940 KB
testcase_18 AC 538 ms
6,940 KB
testcase_19 AC 382 ms
6,944 KB
testcase_20 AC 520 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int T,a,b,c,d,e;
long mod=1e9+7;
int dp[2][20202];
const int off=10100;
main()
{
	cin>>T>>a>>b>>c>>d>>e;
	int now=0;
	dp[now][off]=1;
	for(int i=0;i<T;i++)
	{
		for(int j=0;j<20202;j++)dp[1-now][j]=0;
		for(int j=-10000;j<=10000;j++)
		{
			int t=dp[now][j+off];
			(dp[1-now][j-a+off]+=t)%=mod;
			(dp[1-now][j+a+off]+=t)%=mod;
			(dp[1-now][j-b+off]+=t)%=mod;
			(dp[1-now][j+b+off]+=t)%=mod;
			(dp[1-now][j-c+off]+=t)%=mod;
			(dp[1-now][j+c+off]+=t)%=mod;
		}
		now=1-now;
	}
	long ans=0;
	for(int j=d;j<=e;j++)(ans+=dp[now][j+off])%=mod;
	cout<<ans<<endl;
}
0