結果

問題 No.612 Move on grid
ユーザー wajima_wataruwajima_wataru
提出日時 2018-01-05 20:54:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,500 ms
コード長 979 bytes
コンパイル時間 689 ms
コンパイル使用メモリ 77,524 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 20:22:54
合計ジャッジ時間 1,885 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 15 ms
4,380 KB
testcase_05 AC 31 ms
4,376 KB
testcase_06 AC 32 ms
4,376 KB
testcase_07 AC 14 ms
4,376 KB
testcase_08 AC 31 ms
4,380 KB
testcase_09 AC 19 ms
4,380 KB
testcase_10 AC 13 ms
4,380 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 19 ms
4,380 KB
testcase_13 AC 8 ms
4,376 KB
testcase_14 AC 24 ms
4,376 KB
testcase_15 AC 6 ms
4,376 KB
testcase_16 AC 28 ms
4,376 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 23 ms
4,376 KB
testcase_19 AC 11 ms
4,376 KB
testcase_20 AC 15 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <functional>
#include "math.h"
using namespace std;
typedef long long ll;

int main() {
	ll mod = 1000000007;
    int T, a, b, c, d, e;
    cin >> T >> a >> b >> c >> d >> e;
	a = abs(a); b = abs(b); c = abs(c);	
	if (b < c) swap(b, c); if (a < b) swap(a, b);
	ll nums[20002] = {0};
	nums[10001] = 1;
	int l = 0; int r = 1;
	for (int i = 0; i < T; ++i) {
		l -= a; r += a;
		ll cur_nums[20002] = {0};
		for (int j = 10001 + l; j < 10001 + r; ++j) {
			if (nums[j] != 0) {
				cur_nums[j + a] += nums[j] % mod;
				cur_nums[j - a] += nums[j] % mod;
				cur_nums[j + b] += nums[j] % mod;
				cur_nums[j - b] += nums[j] % mod;
				cur_nums[j + c] += nums[j] % mod;
				cur_nums[j - c] += nums[j] % mod;
			}
		}
		swap(nums, cur_nums);			
	}
	ll ans = 0;
	for (int i = 10001 + d; i < 10002 + e; ++i) {
		ans += nums[i] % mod;
	}
	cout << ans % mod << endl;
}
0