結果
| 問題 |
No.425 ジャンケンの必勝法
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-22 23:20:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 658 bytes |
| コンパイル時間 | 223 ms |
| コンパイル使用メモリ | 39,808 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 19:31:44 |
| 合計ジャッジ時間 | 1,007 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 18 |
ソースコード
#include <cstdio>
#include <array>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
int main() {
int p, q; scanf("%d%d", &p, &q);
double ans = 1/3.;
array<double,101> cur = {}; cur[p] = 1/3.;
repeat (iteration,10000) {
array<double,101> nxt = {};
repeat (i,101) {
// use
ans += 1/2. * cur[i] * i/100.;
nxt[max(0, i-q)] += 1/2. * cur[i] * i/100.;
// don't
ans += 1/3. * cur[i] * (100-i)/100.;
nxt[min(100, i+q)] += 1/3. * cur[i] * (100-i)/100.;
}
cur.swap(nxt);
}
printf("%.12lf\n", ans);
return 0;
}