結果
| 問題 |
No.425 ジャンケンの必勝法
|
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-09-23 01:08:32 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,165 bytes |
| コンパイル時間 | 706 ms |
| コンパイル使用メモリ | 80,016 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 15:44:45 |
| 合計ジャッジ時間 | 1,518 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 17 WA * 1 |
ソースコード
#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;
}
kurenai3110