結果
問題 | No.425 ジャンケンの必勝法 |
ユーザー |
![]() |
提出日時 | 2016-09-28 14:29:29 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 1,112 bytes |
コンパイル時間 | 1,439 ms |
コンパイル使用メモリ | 158,624 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-21 07:55:56 |
合計ジャッジ時間 | 2,284 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h>using namespace std;const double pi = 2 * acos(0.0);const double eps = 1e-8;#define REP(i,a,b) for(int i=(a); i<(b);++i)#define rep(i,n) REP(i,0,n)#define INF (1<<29)#define INFLL (1L<<29)typedef long long ll;typedef unsigned long long ull;typedef pair<int, int> pii;typedef pair<ll, ll> pll;typedef int Cost;struct Edge {int src, dst; Cost cost;Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}};typedef vector<Edge> Edges;typedef vector<Edges> Graph;typedef vector<Cost> Array;typedef vector<Array> Matrix;int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};double p, q;double solve(double p, int depth) {if (depth > 20) return 1;double _p = 0;_p += p / 2;_p += p / 2 * solve(max(0.0, p - q), depth + 1);_p += (1.0 - p) / 3;_p += (1.0 - p) / 3 * solve(min(1.0, p + q), depth + 1);return _p;}int main(void) {ios_base::sync_with_stdio(false); cin.tie(0);cin >> p >> q;p /= 100.0; q /= 100.0;cout << fixed << setprecision(10) << (1.0 + solve(p, 0)) / 3.0 << endl;return 0;}