結果
問題 | No.425 ジャンケンの必勝法 |
ユーザー |
![]() |
提出日時 | 2016-12-02 00:36:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 1,233 bytes |
コンパイル時間 | 918 ms |
コンパイル使用メモリ | 79,592 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 16:52:45 |
合計ジャッジ時間 | 2,024 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 18 |
ソースコード
#include <algorithm>#include <complex>#include <iostream>#include <map>#include <queue>#include <set>#include <string>#include <vector>#define rep(i, n) for (int i = 0; i < (n); i++)#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)using namespace std;typedef long long int lli;typedef pair<lli, lli> P;lli MOD = 1000000007;double f(double, int);double g(double, int);double p, q;double r = 1.0 / 3.0;double fdp[105] = {};double gdp[105] = {};double f(double x, int dph){int xx = (int)(x * 100);//if (fdp[xx] != 0)//return fdp[xx];double tp = min(1.0, x + q);if (dph == 0)return 0;return fdp[xx] = tp * 0.5 + tp * 0.5 * g(tp, dph - 1) + (1 - tp) * r + (1 - tp) * r * f(tp, dph - 1);}double g(double x, int dph){int xx = (int)(x * 100);//if (gdp[xx] != 0)//return gdp[xx];double tp = max(0.0, x - q);if (dph == 0)return 0;return gdp[xx] = tp * 0.5 + tp * 0.5 * g(tp, dph - 1) + (1 - tp) * r + (1 - tp) * r * f(tp, dph - 1);}int main(){cin >> p >> q;p /= 100.0;q /= 100.0;double ans = 0;ans = r + r * (p * 0.5 + p * 0.5 * g(p, 20) + (1 - p) * r + (1 - p) * r * f(p, 20));printf("%.10f\n", ans);}