結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー kotamanegikotamanegi
提出日時 2017-03-25 00:00:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 1,992 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 102,804 KB
実行使用メモリ 81,668 KB
最終ジャッジ日時 2023-09-20 06:22:56
合計ジャッジ時間 4,847 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 197 ms
81,544 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 195 ms
81,668 KB
testcase_07 AC 199 ms
81,436 KB
testcase_08 AC 197 ms
81,524 KB
testcase_09 AC 196 ms
81,512 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 29 ms
17,328 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 8 ms
5,620 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 200 ms
81,504 KB
testcase_19 AC 199 ms
81,592 KB
testcase_20 AC 199 ms
81,500 KB
testcase_21 AC 197 ms
81,552 KB
testcase_22 AC 199 ms
81,604 KB
testcase_23 AC 198 ms
81,536 KB
testcase_24 AC 198 ms
81,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <random>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
long long solve(long long n) {
	long long ans = 1;
	for (int i = 1;i <= n;++i) {
		ans *= i;
		ans %= MAX_MOD;
	}
	return ans;
}
long long gyaku(long long n) {
	long long hogee = MAX_MOD - 2;
	long long nya = n;
	long long ans = 1;
	while (hogee != 0) {
		if (hogee % 2 == 1) {
			ans *= nya;
			ans %= MAX_MOD;
		}
		hogee /= 2;
		nya *= nya;
		nya %= MAX_MOD;
	}
	return ans;
}
int main() {
	long long gx, gy, k;
	cin >> gx >> gy >> k;
	vector<vector<long long>> wow[100];
	vector<long long> hoge;
	wow[0].push_back(hoge);
	vector<pair<long long, long long>> magic;
	for (long long i = 0;i < k;++i) {
		long long x, y, n;
		cin >> x >> y >> n;
		magic.push_back(make_pair(x, y));
		for (long long j = 0;j < wow[i].size();++j) {
			for (long long q = 0;q <= n;++q) {
				vector<long long> hogehoge = wow[i][j];
				hogehoge.push_back(q);
				wow[i + 1].push_back(hogehoge);
			}
		}
	}
	long long ans = 0;
	for (long long i = 0;i < wow[k].size();++i) {
		long long xs=0, ys=0,sum=0;
		for (long long j = 0;j < wow[k][i].size();++j) {
			xs += wow[k][i][j] * magic[j].first;
			ys += wow[k][i][j] * magic[j].second;
			sum += wow[k][i][j];
		}
		if (xs == gx&&ys == gy) {
			long long nya = solve(sum)%MAX_MOD;
			for (long long j = 0;j < wow[k][i].size();++j) {
				nya *= gyaku(solve(wow[k][i][j])%MAX_MOD);
				nya %= MAX_MOD;
			}
			ans += nya;
			ans %= MAX_MOD;
		}
	}
	cout << ans << endl;
	return 0;
}
0