結果
問題 | No.1682 Unfair Game |
ユーザー | nawawan |
提出日時 | 2021-09-17 23:02:50 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,312 bytes |
コンパイル時間 | 2,159 ms |
コンパイル使用メモリ | 211,696 KB |
実行使用メモリ | 29,024 KB |
最終ジャッジ日時 | 2024-06-29 21:50:35 |
合計ジャッジ時間 | 3,258 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
13,728 KB |
testcase_01 | AC | 5 ms
13,640 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 23 ms
28,900 KB |
testcase_08 | WA | - |
testcase_09 | AC | 18 ms
28,616 KB |
testcase_10 | WA | - |
testcase_11 | AC | 16 ms
25,676 KB |
testcase_12 | AC | 19 ms
28,824 KB |
testcase_13 | WA | - |
testcase_14 | AC | 5 ms
13,576 KB |
testcase_15 | AC | 5 ms
13,772 KB |
testcase_16 | AC | 6 ms
13,564 KB |
testcase_17 | AC | 6 ms
13,768 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 24 ms
29,004 KB |
testcase_21 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; template<const int MOD> struct modint{ long long val; modint(): val(0) {} modint(long long x){ if(x < 0) val = x % MOD + MOD; else val = x % MOD; } modint(const modint &t){ val = t.val; } modint& operator =(const modint m){ val = m.val; return *this; } modint operator -(){ return modint(-val); } modint& operator-=(const modint &m){ val -= m.val; if(val < 0) val += MOD; return *this; } modint& operator+=(const modint &m){ val += m.val; if(val >= MOD) val -= MOD; return *this; } modint& operator*=(const modint &m){ val *= m.val; val %= MOD; return *this; } modint& operator/=(modint m){ *this *= m.inv(); return *this; } modint inv(){ long long x = 1, y = 0; long long a = val, b = MOD; while(b != 0){ long long t = a / b; a -= t * b; x -= t * y; swap(a, b); swap(x, y); } x %= MOD; if(x < 0) x += MOD; return modint(x); } modint pow(long long k){ long long res = 1; long long v = val; while(k > 0){ if(k & 1) res = res * v % MOD; v = v * v % MOD; k >>= 1; } return modint(res); } bool operator==(const modint &m){ return val == m.val; } modint operator+(const modint &m){ return modint(*this) += m; } modint operator-(const modint &m){ return modint(*this) -= m; } modint operator*(const modint &m){ return modint(*this) *= m; } modint operator/(const modint &m){ return modint(*this) /= m; } bool operator!=(const modint &m){ return modint(*this).val != m.val; } bool operator!=(const int &m){ return modint(*this).val != m; } }; const int MOD = 1000000007; using mint = modint<MOD>; const int MAX = 410000; mint fac[MAX], finv[MAX], inv[MAX]; void COMinit(){ fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for(int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i; inv[i] = mint(MOD) - inv[MOD % i] * (MOD / i); finv[i] = finv[i - 1] * inv[i]; } } mint COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * finv[k] * finv[n - k]; } int main(){ int N; cin >> N; vector<int> P(N); for(int i = 0; i < N; i++) cin >> P[i]; vector<vector<vector<mint>>> dp(N + 1, vector<vector<mint>>(2, vector<mint>(10001))); dp[0][0][10000] = 1; for(int i = 0; i < N; i++){ for(int j = 0; j < 2; j++){ for(int k = 0; k < 10001; k++){ if(dp[i][j][k] == 0) continue; int l = k * P[i]; int r = k * (100 - P[i]); l /= 100; r /= 100; dp[i + 1][(j + 1) % 2][l] += dp[i][j][k]; dp[i + 1][j][r] += dp[i][j][k]; dp[i + 1][j][k] += dp[i][j][k]; } } } mint ans = 0; for(int i = 5001; i < 10001; i++){ ans += dp[N][1][i]; } cout << ans.val << endl; }