結果
問題 | No.162 8020運動 |
ユーザー | maine_honzuki |
提出日時 | 2020-06-01 16:30:18 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,345 bytes |
コンパイル時間 | 1,708 ms |
コンパイル使用メモリ | 167,824 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-05-01 17:23:28 |
合計ジャッジ時間 | 18,981 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 392 ms
6,816 KB |
testcase_01 | AC | 3,909 ms
5,376 KB |
testcase_02 | TLE | - |
testcase_03 | TLE | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int A, N; double P[3]; cin >> A >> P[0] >> P[1] >> P[2]; N = 80 - A; for (int i = 0; i < 3; i++) { P[i] /= 100; } double dp[2][1 << 14] = {}; int now = 0, nxt = 1; dp[now][(1 << 14) - 1] = 1; auto prob = [&](int bit, int mask) { double ret = 1; for (int x = 0; x < 14; x++) { int cnt = 0; if (x != 0 && (bit & (1 << (x - 1)))) cnt++; if (x != 13 && (bit & (1 << (x + 1)))) cnt++; if (bit & (1 << x) && !(mask & (1 << x))) ret *= P[cnt]; else if (bit & (1 << x) && (mask & (1 << x))) ret *= 1 - P[cnt]; } return ret; }; while (N--) { for (int bit = 0; bit < (1 << 14); bit++) { dp[nxt][bit] = 0; } for (int bit = 0; bit < (1 << 14); bit++) { for (int mask = bit; mask >= 0; mask--) { mask &= bit; dp[nxt][mask] += dp[now][bit] * prob(bit, mask); } } swap(now, nxt); } double ans = 0; for (int bit = 0; bit < (1 << 14); bit++) { ans += dp[now][bit] * __builtin_popcount(bit); } cout << fixed << setprecision(10) << ans * 2 << endl; }