結果

問題 No.162 8020運動
ユーザー kimiyukikimiyuki
提出日時 2017-01-05 01:21:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,629 ms / 5,000 ms
コード長 869 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 32,284 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 12:14:36
合計ジャッジ時間 50,370 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
4,380 KB
testcase_01 AC 1,308 ms
4,376 KB
testcase_02 AC 1,960 ms
4,376 KB
testcase_03 AC 2,615 ms
4,376 KB
testcase_04 AC 2,615 ms
4,380 KB
testcase_05 AC 2,629 ms
4,376 KB
testcase_06 AC 2,614 ms
4,376 KB
testcase_07 AC 2,612 ms
4,380 KB
testcase_08 AC 2,615 ms
4,376 KB
testcase_09 AC 132 ms
4,376 KB
testcase_10 AC 1,960 ms
4,380 KB
testcase_11 AC 1,309 ms
4,376 KB
testcase_12 AC 656 ms
4,376 KB
testcase_13 AC 2,613 ms
4,376 KB
testcase_14 AC 263 ms
4,376 KB
testcase_15 AC 262 ms
4,376 KB
testcase_16 AC 785 ms
4,376 KB
testcase_17 AC 393 ms
4,380 KB
testcase_18 AC 2,493 ms
4,380 KB
testcase_19 AC 1,828 ms
4,384 KB
testcase_20 AC 2,089 ms
4,380 KB
testcase_21 AC 2,091 ms
4,380 KB
testcase_22 AC 1,957 ms
4,376 KB
testcase_23 AC 2,093 ms
4,376 KB
testcase_24 AC 1,962 ms
4,376 KB
testcase_25 AC 2,220 ms
4,376 KB
testcase_26 AC 132 ms
4,376 KB
testcase_27 AC 1,437 ms
4,380 KB
testcase_28 AC 2,483 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
const int K = 14;
int main() {
    int a; scanf("%d", &a);
    double p[3]; repeat (i,3) { scanf("%lf", &p[i]); p[i] /= 100; }
    double dp[1<<K] = {};
    dp[(1<<K) - 1] = 1;
    for (; a < 80; ++ a) {
        repeat (s, 1<<K) {
            double q = 0;
            for (int t = s; t < (1<<K); ++ t |= s) { // s \subseteq t
                double r = dp[t];
                for (int i = t & - t; i; i = t ^ (t & (t - (i << 1)))) {
                    int j = bool(t & (i>>1)) + bool(t & (i<<1));
                    r *= (s & i ? 1 - p[j] : p[j]);
                }
                q += r;
            }
            dp[s] = q;
        }
    }
    double acc = 0;
    repeat (s, 1<<K) acc += __builtin_popcount(s) * dp[s];
    printf("%.9lf\n", acc * 2);
    return 0;
}
0