結果

問題 No.425 ジャンケンの必勝法
ユーザー btk
提出日時 2016-09-22 15:07:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 334 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 1,659 ms
コンパイル使用メモリ 170,360 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-17 19:04:28
合計ジャッジ時間 10,039 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

struct cww{
    cww(){
        ios::sync_with_stdio(false);cin.tie(0);
        cout<<fixed<<setprecision(20);
    }
}init;

typedef __float128 D;
typedef vector<D> VD;

ostream& operator<<(ostream &os,__float128 f){
    os<<(double)f;
    return os;
}
istream& operator>>(istream &is,__float128 &f){
    double x;
    is>>x;f=x;
    return is;
}
const D d2=200;
const D d3=300;
const int loop=10000;
int main(){
    int p,q;
    cin>>p>>q;
    //q==0だけ場合分け
    D res=0;
    VD P(101,0);
    for(int i=0;i<loop;i++){
        VD Q(101);
        for(int j=0;j<=100;j++)
            Q[j]=(j/d2)*(1+P[max(j-q,0)])+((100-j)/d3)*(1+P[min(j+q,100)]);
        swap(P,Q);
    }
    
    cout<<1.0/3+P[p]/3.0<<endl;
    return 0;
}
0