結果

問題 No.425 ジャンケンの必勝法
ユーザー tubo28tubo28
提出日時 2016-09-22 23:52:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 1,601 ms
コンパイル使用メモリ 167,420 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 20:00:58
合計ジャッジ時間 2,411 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

int p0, q;

const int LIM = 10;
ld dp[101][LIM+1];

ld f(int p, int r) {
    ld &res = dp[p][r];
    if (res >= -1) return res;

    res = 0;
    if(r < LIM){
        ld p_ = p / 100.0;
        res += p_     * (1.0/2) * f(max(0,   p-q), r+1); // d
        res += p_     * (1.0/2) * 1; // w
        res += (1-p_) * (1.0/3) * 0; // l
        res += (1-p_) * (1.0/3) * f(min(100, p+q), r+1); // d
        res += (1-p_) * (1.0/3) * 1; // w
    }
    return res;
}

int main() {
    while (cin >> p0 >> q) {
        fill((ld*)begin(dp), (ld*)end(dp), -10);
        ld ans = (f(p0,0)+1) / 3;
        printf("%.10lf\n", (double)ans);
    }
}
0