結果

問題 No.612 Move on grid
ユーザー kotatsugame
提出日時 2020-03-11 06:23:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 738 ms / 2,500 ms
コード長 604 bytes
コンパイル時間 1,006 ms
コンパイル使用メモリ 65,736 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-15 23:58:05
合計ジャッジ時間 9,937 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
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