結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー kotamanegikotamanegi
提出日時 2017-03-24 23:46:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,183 bytes
コンパイル時間 1,360 ms
コンパイル使用メモリ 101,724 KB
実行使用メモリ 81,876 KB
最終ジャッジ日時 2023-09-20 05:36:54
合計ジャッジ時間 4,934 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,376 KB
testcase_04 AC 203 ms
81,540 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 206 ms
81,728 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 203 ms
81,776 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 30 ms
16,456 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 9 ms
5,684 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 205 ms
81,544 KB
testcase_19 AC 204 ms
81,768 KB
testcase_20 AC 204 ms
81,508 KB
testcase_21 AC 206 ms
81,588 KB
testcase_22 AC 206 ms
81,804 KB
testcase_23 AC 206 ms
81,676 KB
testcase_24 AC 204 ms
81,656 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 kaijo[10000] = {};
long long solve(long long n) {
	if (kaijo[n]) return kaijo[n];
	return kaijo[n] = (n*solve(n - 1))%MAX_MOD;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
long long lcm(long long a, long long b) {
	return a*b / gcd(a, b);
}
long long ex_gcd(long long a, long long b, long long &c, long long &d) {
	long long g = a;
	c = 1;
	d = 0;
	if (b != 0) g = ex_gcd(b, a%b,d,c), d -= (a / b) * c;
	return g;
}
long long gyaku(long long n) {
	long long x, y;
	if (ex_gcd(n, MAX_MOD, x, y) == 1) return (x + MAX_MOD) % MAX_MOD;
	return 0;
}
int main() {
#define int long long
	kaijo[1] = 1;
	int gx, gy, k;
	cin >> gx >> gy >> k;
	vector<vector<int>> wow[100];
	vector<int> hoge;
	wow[0].push_back(hoge);
	vector<pair<int, int>> magic;
	for (int i = 0;i < k;++i) {
		int x, y, n;
		cin >> x >> y >> n;
		magic.push_back(make_pair(x, y));
		for (int j = 0;j < wow[i].size();++j) {
			for (int q = 0;q <= n;++q) {
				vector<int> hogehoge = wow[i][j];
				hogehoge.push_back(q);
				wow[i + 1].push_back(hogehoge);
			}
		}
	}
	long long ans = 0;
	for (int i = 0;i < wow[k].size();++i) {
		int xs=0, ys=0,sum=0;
		for (int 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);
			for (int j = 0;j < wow[k][i].size();++j) {
				if(wow[k][i][j] != 0)
				nya *= gyaku(solve(wow[k][i][j])%MAX_MOD);
				nya %= MAX_MOD;
			}
			ans += nya;
			ans %= MAX_MOD;
		}
	}
	cout << ans << endl;
	return 0;
}
0