結果

問題 No.425 ジャンケンの必勝法
ユーザー kimiyukikimiyuki
提出日時 2016-09-22 23:20:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 39,044 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 05:47:20
合計ジャッジ時間 1,536 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,380 KB
testcase_01 AC 7 ms
4,376 KB
testcase_02 AC 6 ms
4,380 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 6 ms
4,376 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 6 ms
4,384 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 AC 7 ms
4,376 KB
testcase_14 AC 6 ms
4,376 KB
testcase_15 AC 6 ms
4,380 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 6 ms
4,376 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 6 ms
4,376 KB
testcase_21 AC 6 ms
4,380 KB
testcase_22 AC 6 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <array>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
int main() {
    int p, q; scanf("%d%d", &p, &q);
    double ans = 1/3.;
    array<double,101> cur = {}; cur[p] = 1/3.;
    repeat (iteration,10000) {
        array<double,101> nxt = {};
        repeat (i,101) {
            // use
            ans += 1/2. * cur[i] * i/100.;
            nxt[max(0, i-q)] += 1/2. * cur[i] * i/100.;
            // don't
            ans += 1/3. * cur[i] * (100-i)/100.;
            nxt[min(100, i+q)] += 1/3. * cur[i] * (100-i)/100.;
        }
        cur.swap(nxt);
    }
    printf("%.12lf\n", ans);
    return 0;
}
0