結果

問題 No.425 ジャンケンの必勝法
ユーザー confconf
提出日時 2016-09-22 23:16:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 59,060 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-11 05:46:06
合計ジャッジ時間 1,578 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
double p0,q;
const double eps = 10e-16;

double rec(double p, double c, bool b){
    if(c<eps) return 0;
    double ret=0;
    if(b){
        ret+=c/2;
        p=max(p-q,0.0);
        ret+=rec(p,c/2*p,true)+rec(p,c/2*(1-p),false);
        return ret;
    }else{
        ret+=c/3;
        p=min(p+q,1.0);
        ret+=rec(p,c/3*p,true)+rec(p,c/3*(1-p),false);
        return ret;
    }
}

int main(){
    cin>>p0>>q;
    p0/=100;q/=100;
    cout<<fixed;
    cout.precision(12);
    cout<<1/3.0+rec(p0,1/3.0*p0,true)+rec(p0,1/3.0*(1-p0),false)<<endl;
    return 0;
}
0