結果

問題 No.612 Move on grid
ユーザー Sebastian KingSebastian King
提出日時 2017-12-12 00:58:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 58 ms / 2,500 ms
コード長 1,030 bytes
コンパイル時間 1,178 ms
コンパイル使用メモリ 145,148 KB
実行使用メモリ 24,996 KB
最終ジャッジ日時 2023-08-22 22:11:23
合計ジャッジ時間 2,644 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 6 ms
4,580 KB
testcase_04 AC 33 ms
24,964 KB
testcase_05 AC 58 ms
24,968 KB
testcase_06 AC 57 ms
24,936 KB
testcase_07 AC 35 ms
24,944 KB
testcase_08 AC 58 ms
24,996 KB
testcase_09 AC 32 ms
14,236 KB
testcase_10 AC 24 ms
11,344 KB
testcase_11 AC 8 ms
5,676 KB
testcase_12 AC 34 ms
15,772 KB
testcase_13 AC 14 ms
7,932 KB
testcase_14 AC 44 ms
19,892 KB
testcase_15 AC 10 ms
5,912 KB
testcase_16 AC 50 ms
22,604 KB
testcase_17 AC 12 ms
7,892 KB
testcase_18 AC 42 ms
19,080 KB
testcase_19 AC 22 ms
12,580 KB
testcase_20 AC 31 ms
16,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int a, b, c, d, e;
int T;

int f[502][20010];

void upd(int &x, int y){
	x += y;
	if (x >= MM) x -= MM;
}

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	cin >> T;
	cin >> a >> b >> c >> d >> e;
	f[0][10000] = 1;
	for (int i = 1; i <= T; i++){
		for (int j = 0; j <= 20000; j++)
			if (f[i-1][j]){
				upd(f[i][j+a], f[i-1][j]);
				upd(f[i][j+b], f[i-1][j]);
				upd(f[i][j+c], f[i-1][j]);
				upd(f[i][j-a], f[i-1][j]);
				upd(f[i][j-b], f[i-1][j]);
				upd(f[i][j-c], f[i-1][j]);
			}
	}
	ll ans = 0;
	for (int i = d + 10000; i <= e + 10000; i++){
		ans += f[T][i];
	}
	printf("%lld\n", ans % MM);
}

void printans(){

}


int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

0