結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー fiordfiord
提出日時 2017-03-28 19:16:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 979 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 71,396 KB
実行使用メモリ 19,812 KB
最終ジャッジ日時 2023-09-20 18:34:02
合計ジャッジ時間 2,223 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 34 ms
19,572 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 30 ms
19,568 KB
testcase_07 AC 30 ms
19,680 KB
testcase_08 AC 30 ms
19,764 KB
testcase_09 AC 30 ms
19,520 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 9 ms
8,984 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 7 ms
8,160 KB
testcase_14 AC 3 ms
4,628 KB
testcase_15 AC 3 ms
4,504 KB
testcase_16 AC 4 ms
5,064 KB
testcase_17 AC 4 ms
4,872 KB
testcase_18 AC 29 ms
19,720 KB
testcase_19 AC 30 ms
19,812 KB
testcase_20 AC 30 ms
19,516 KB
testcase_21 AC 29 ms
19,512 KB
testcase_22 AC 30 ms
19,564 KB
testcase_23 AC 30 ms
19,504 KB
testcase_24 AC 29 ms
19,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n)	for(int i=0;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
const ll mod = 1e9 + 7;
ll dp[20][20][20][20][20];
int x[5], y[5], n[5];
int main() {
	int gx, gy, k;	cin >> gx >> gy >> k;
	rep(i,k)	cin >> x[i] >> y[i] >> n[i];
	dp[0][0][0][0][0] = 1;
	ll ret = 0;
	REP(a, n[0])	REP(b, n[1])	REP(c, n[2])	REP(d, n[3])	REP(e, n[4]) {
		if (dp[a][b][c][d][e] == 0)	continue;
		int cx = x[0] * a + x[1] * b + x[2] * c + x[3] * d + x[4] * e;
		int cy = y[0] * a + y[1] * b + y[2] * c + y[3] * d + y[4] * e;
		if (cx == gx&&cy == gy)	(ret += dp[a][b][c][d][e]) %= mod;
		(dp[a + 1][b][c][d][e] += dp[a][b][c][d][e]) %= mod;
		(dp[a][b + 1][c][d][e] += dp[a][b][c][d][e]) %= mod;
		(dp[a][b][c + 1][d][e] += dp[a][b][c][d][e]) %= mod;
		(dp[a][b][c][d + 1][e] += dp[a][b][c][d][e]) %= mod;
		(dp[a][b][c][d][e + 1] += dp[a][b][c][d][e]) %= mod;
	}
	cout << ret << endl;
}
0