結果

問題 No.612 Move on grid
ユーザー Jumbo_kprJumbo_kpr
提出日時 2019-07-28 13:39:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 310 ms / 2,500 ms
コード長 1,960 bytes
コンパイル時間 1,059 ms
コンパイル使用メモリ 104,396 KB
実行使用メモリ 239,964 KB
最終ジャッジ日時 2023-09-15 11:30:18
合計ジャッジ時間 6,447 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 4 ms
4,704 KB
testcase_02 AC 6 ms
6,208 KB
testcase_03 AC 77 ms
60,104 KB
testcase_04 AC 309 ms
239,856 KB
testcase_05 AC 306 ms
239,744 KB
testcase_06 AC 307 ms
239,856 KB
testcase_07 AC 308 ms
239,740 KB
testcase_08 AC 309 ms
239,780 KB
testcase_09 AC 310 ms
239,964 KB
testcase_10 AC 196 ms
150,860 KB
testcase_11 AC 94 ms
73,320 KB
testcase_12 AC 229 ms
179,144 KB
testcase_13 AC 131 ms
102,060 KB
testcase_14 AC 280 ms
208,100 KB
testcase_15 AC 100 ms
77,564 KB
testcase_16 AC 303 ms
237,016 KB
testcase_17 AC 137 ms
106,528 KB
testcase_18 AC 270 ms
212,284 KB
testcase_19 AC 212 ms
165,084 KB
testcase_20 AC 289 ms
226,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
//#define int unsigned long long
#define all(x) (x).begin(), (x).end()
#define double long double

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;
long long fac[MAX], finv[MAX], inv[MAX];


int dp[550][100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	dp[0][50000] = 1;
	int T, a, b, c, d, e; cin >> T >> a >> b >> c >> d >> e;
	FOR(i, 0, T) {
		FOR(j, 20000, 80001) {
			dp[i + 1][j] += dp[i][j - a] + dp[i][j + a] + dp[i][j - b] + dp[i][j + b] + dp[i][j - c] + dp[i][j + c];
			dp[i + 1][j] %= MOD;
		}
	}
	int ans = 0;
	FOR(j, 50000 + d, 50000 + e + 1) {
		ans += dp[T][j];
		ans %= MOD;
	}
	print(ans);
}

0