結果
問題 | No.498 ワープクリスタル (給料日編) |
ユーザー |
|
提出日時 | 2017-08-30 22:49:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 2,701 bytes |
コンパイル時間 | 1,550 ms |
コンパイル使用メモリ | 167,244 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-06 14:36:20 |
合計ジャッジ時間 | 2,663 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
// {{{ Templates#include <bits/stdc++.h>#define show(x) cerr << #x << " = " << x << endlusing namespace std;using ll = long long;using pii = pair<int, int>;using vi = vector<int>;template <typename T>ostream& operator<<(ostream& os, const vector<T>& v){os << "sz:" << v.size() << "\n[";for (const auto& p : v) {os << p << ",";}os << "]\n";return os;}template <typename S, typename T>ostream& operator<<(ostream& os, const pair<S, T>& p){os << "(" << p.first << "," << p.second<< ")";return os;}constexpr ll MOD = (ll)1e9 + 7LL;template <typename T>constexpr T INF = numeric_limits<T>::max() / 100;// }}}constexpr int MAX = 100;ll combi[MAX + 1][MAX + 1];ll comb(ll i, ll j, ll k, ll l, ll m){ll prod = 1;ll sum = i + j + k + l + m;prod = (prod * combi[sum][i]) % MOD;sum -= i;prod = (prod * combi[sum][j]) % MOD;sum -= j;prod = (prod * combi[sum][k]) % MOD;sum -= k;prod = (prod * combi[sum][l]) % MOD;return prod;}int main(){cin.tie(0);ios::sync_with_stdio(false);combi[0][0] = 1;for (ll i = 1; i <= MAX; i++) {for (ll j = 0; j <= MAX; j++) {if (j == 0) {combi[i][j] = 1;} else {combi[i][j] = (combi[i - 1][j - 1] + combi[i - 1][j]) % MOD;}}}ll gx, gy;cin >> gx >> gy;ll k;cin >> k;array<ll, 5> x;array<ll, 5> y;array<ll, 5> num;for (ll i = 0; i < 5; i++) {if (i < k) {cin >> x[i] >> y[i] >> num[i];} else {x[i] = 0;y[i] = 0;num[i] = 0;}}ll cnt = 0;for (ll i = 0; i <= num[0]; i++) {const ll x0 = x[0] * i;const ll y0 = y[0] * i;for (ll j = 0; j <= num[1]; j++) {const ll x1 = x[1] * j;const ll y1 = y[1] * j;for (ll k = 0; k <= num[2]; k++) {const ll x2 = x[2] * k;const ll y2 = y[2] * k;for (ll l = 0; l <= num[3]; l++) {const ll x3 = x[3] * l;const ll y3 = y[3] * l;for (ll m = 0; m <= num[4]; m++) {const ll X = x0 + x1 + x2 + x3 + x[4] * m;const ll Y = y0 + y1 + y2 + y3 + y[4] * m;if (X == gx and Y == gy) {cnt += comb(i, j, k, l, m);cnt = cnt % MOD;}}}}}}cout << cnt << endl;return 0;}