結果
| 問題 |
No.425 ジャンケンの必勝法
|
| コンテスト | |
| ユーザー |
conf
|
| 提出日時 | 2016-09-22 23:16:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 626 bytes |
| コンパイル時間 | 516 ms |
| コンパイル使用メモリ | 57,432 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 19:28:37 |
| 合計ジャッジ時間 | 1,372 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 18 |
ソースコード
#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;
}
conf