結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー char134217728char134217728
提出日時 2017-08-20 02:46:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,236 bytes
コンパイル時間 2,339 ms
コンパイル使用メモリ 160,744 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 17:26:04
合計ジャッジ時間 3,223 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 6 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 6 ms
5,376 KB
testcase_19 AC 7 ms
5,376 KB
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 7 ms
5,376 KB
testcase_23 AC 7 ms
5,376 KB
testcase_24 AC 7 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:27:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   27 | main(){
      | ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORN(i,a,b) for (i=(a);i<=(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

int g[2], k, x[2][5], n[5], i[5], _g[2];
ll fac[80], inv[80];
ll powMod(ll a, ll n, ll m){
  ll p = 1;
  while(n > 0){
    if(n & 1) p = p * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return p;
}

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  fac[0] = 1;
  inv[0] = 1;
  FOR(i, 1, 80){
    fac[i] = fac[i-1] * i % mod;
    inv[i] = powMod(fac[i], mod - 2, mod);
  }
  cin >> g[0] >> g[1] >> k;
  FOR(i, 0, k){
    cin >> x[0][i] >> x[1][i] >> n[i];
  }
  ll ans = 0;
  FORN(i[4], 0, n[4])FORN(i[3], 0, n[3])FORN(i[2], 0, n[2])FORN(i[1], 0, n[1])FORN(i[0], 0, n[0]){
    _g[0] = g[0];
    _g[1] = g[1];
    FOR(j, 0, k){
      FOR(l, 0, 2){
        _g[l] -= i[j] * x[l][j];
      }
    }
    if(_g[0] != 0 || _g[1] != 0)continue;
    ll p = fac[i[0] + i[1] + i[2] + i[3] + i[4]];
    FOR(j, 0, k){
      p = p * inv[i[j]] % mod;
    }
    ans += p;
  }
  cout << ans % mod << endl;
}
0