結果
| 問題 |
No.425 ジャンケンの必勝法
|
| コンテスト | |
| ユーザー |
tossy
|
| 提出日時 | 2016-09-22 23:53:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 999 bytes |
| コンパイル時間 | 658 ms |
| コンパイル使用メモリ | 88,768 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 19:42:56 |
| 合計ジャッジ時間 | 1,365 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 18 |
ソースコード
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second
#define INF 2147483600
double v[101];
double s[101];
int main(){
int p,q;
cin>>p>>q;
double res=1./3.;
fill(v, v+101, 0.);
v[p]=1./3.;
double *nxt, *prev;
prev = v;
nxt = s;
rep(reps, 1000){
fill(nxt, nxt+101, 0.);
rep(i,101){
if(prev[i]>0){
res += prev[i]*(i/600. + 1./3.);
nxt[max(i-q,0)] += prev[i]*i/200.;
nxt[min(i+q,100)]+=prev[i]*(100-i)/300.;
}
}
swap(prev, nxt);
}
printf("%.7lf\n", res);
return 0;
}
tossy