結果

問題 No.425 ジャンケンの必勝法
ユーザー kurenai3110kurenai3110
提出日時 2016-09-23 01:08:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,165 bytes
コンパイル時間 676 ms
コンパイル使用メモリ 80,132 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 20:23:26
合計ジャッジ時間 1,541 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;
typedef pair<double, int> PP;

int P, Q;

double bfs() {
	queue<PP> que;
	que.push(make_pair(1./3,P));

	double ans = 1. / 3;
	int cnt = 0;
	while (cnt!=100000) {
		pair<double,int> p = que.front(); que.pop();
		//if (p.second > 100)ans += p.first / 2;
		//else if(p.second>=0&&p.second<=100)
			ans += p.first / 2 * p.second/100;
		//if (p.second < 0)ans += p.first / 3;
		//else if(p.second>=0&&p.second<=100)
			ans += p.first / 3 * (100-p.second)/100;
		//cout << ans << endl;

		//cout << p.second << endl;
		if(p.second+Q<100) que.push(make_pair(p.first / 3 * (100 - p.second) / 100,p.second + Q));
		//if (p.second < 100)
		else if(p.second!=100) que.push(make_pair(p.first / 3 * (100 - p.second) / 100, 100));
		if(p.second-Q>0)que.push(make_pair(p.first / 2 * p.second / 100,p.second - Q));
		//if (p.second > 0)
		else if(p.second!=0) que.push(make_pair(p.first / 2 * p.second / 100, 0));
		cnt++;
	}
	return ans;
}

int main()
{
	cin >> P >> Q;
	cout <<fixed<<setprecision(7)<< bfs() << endl;

    return 0;
}
0