結果
| 問題 |
No.425 ジャンケンの必勝法
|
| コンテスト | |
| ユーザー |
tubo28
|
| 提出日時 | 2016-09-22 23:52:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 728 bytes |
| コンパイル時間 | 1,596 ms |
| コンパイル使用メモリ | 167,912 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-17 15:15:02 |
| 合計ジャッジ時間 | 2,426 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 WA * 1 |
| other | AC * 15 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int p0, q;
const int LIM = 17;
ld dp[101][LIM+1];
ld f(int p, int r) {
ld &res = dp[p][r];
if (res >= -1) return res;
res = 0;
if(r < LIM){
ld p_ = p / 100.0;
res += p_ * (1.0/2) * f(max(0, p-q), r+1); // d
res += p_ * (1.0/2) * 1; // w
res += (1-p_) * (1.0/3) * 0; // l
res += (1-p_) * (1.0/3) * f(min(100, p+q), r+1); // d
res += (1-p_) * (1.0/3) * 1; // w
}
return res;
}
int main() {
while (cin >> p0 >> q) {
fill((ld*)begin(dp), (ld*)end(dp), -10);
ld ans = (f(p0,0)+1) / 3;
printf("%.10lf\n", (double)ans);
}
}
tubo28