結果

問題 No.425 ジャンケンの必勝法
ユーザー deark1414deark1414
提出日時 2017-09-11 16:39:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 648 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 65,392 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-07 12:56:46
合計ジャッジ時間 1,738 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include <iomanip>

using namespace std;

void aiko(double tp,double p);
double ans = 1.0 / 3.0;
double q;

int main(){
	int tp,tq;
	cin >> tp >> tq;
	double p;
	
	p = tp / 100.0;
	q = tq / 100.0;
	
	double paiko = 1.0 / 3.0;
	aiko(paiko,p);
	
	cout << fixed << setprecision(7) << ans << endl;
	return 0;
}

void aiko(double tp,double p){
	double duse = 1.0 - p;
	double kati = tp * duse * (1.0 / 3.0);
	double ai = kati;
	ans += kati;
	if(kati > (1.0 / 1e9)) aiko(ai,min(p+q,1.0));
	
	double ukati = tp * p * (1.0 / 2.0);
	double uai = ukati;
	ans += ukati;
	if(ukati > (1.0 / 1e9)) aiko(uai,max(p-q,0.0));
}
0