結果
問題 | No.498 ワープクリスタル (給料日編) |
ユーザー |
![]() |
提出日時 | 2017-03-24 23:34:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 2,879 bytes |
コンパイル時間 | 988 ms |
コンパイル使用メモリ | 102,640 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 00:39:31 |
合計ジャッジ時間 | 1,549 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <iostream>#include <iomanip>#include <cstdio>#include <string>#include <cstring>#include <deque>#include <list>#include <queue>#include <stack>#include <vector>#include <utility>#include <algorithm>#include <map>#include <set>#include <complex>#include <cmath>#include <limits>#include <cfloat>#include <climits>#include <ctime>#include <cassert>using namespace std;#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)#define all(v) begin(v), end(v)#define pb(a) push_back(a)#define fr first#define sc second#define INF 2000000000#define int long long int#define X real()#define Y imag()#define EPS (1e-10)#define EQ(a,b) (abs((a) - (b)) < EPS)#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )#define LE(n, m) ((n) < (m) + EPS)#define LEQ(n, m) ((n) <= (m) + EPS)#define GE(n, m) ((n) + EPS > (m))#define GEQ(n, m) ((n) + EPS >= (m))typedef vector<int> VI;typedef vector<VI> MAT;typedef pair<int, int> pii;typedef long long ll;typedef complex<double> P;typedef pair<P, P> L;typedef pair<P, double> C;int dx[]={1, -1, 0, 0};int dy[]={0, 0, 1, -1};int const MOD = 1000000007;ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}int madd(int a, int b) {return (a + b) % MOD;}int msub(int a, int b) {return (a - b + MOD) % MOD;}int mmul(int a, int b) {return (a * b) % MOD;}int minv(int a) {return mod_pow(a, MOD-2);}int mdiv(int a, int b) {return mmul(a, minv(b));}namespace std {bool operator<(const P& a, const P& b) {return a.X != b.X ? a.X < b.X : a.Y < b.Y;}}signed main() {int gx, gy, k; cin >> gx >> gy >> k;int f[110]; f[0] = 1;repq(i,1,100) {f[i] = mmul(f[i-1], i);}int x[10] = {}, y[10] = {}, n[10] = {};rep(i,0,k) {cin >> x[i] >> y[i] >> n[i];}int ans = 0;repq(a,0,n[0]) {repq(b,0,n[1]) {repq(c,0,n[2]) {repq(d,0,n[3]) {repq(e,0,n[4]) {int sum = a + b + c + d + e;int nx = x[0] * a + x[1] * b + x[2] * c + x[3] * d + x[4] * e;int ny = y[0] * a + y[1] * b + y[2] * c + y[3] * d + y[4] * e;if(nx == gx && ny == gy) {int temp = f[sum];temp = mdiv(temp, f[a]);temp = mdiv(temp, f[b]);temp = mdiv(temp, f[c]);temp = mdiv(temp, f[d]);temp = mdiv(temp, f[e]);ans = madd(ans, temp);}}}}}}cout << ans << endl;return 0;}