結果

問題 No.425 ジャンケンの必勝法
ユーザー btkbtk
提出日時 2016-09-22 15:08:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 749 bytes
コンパイル時間 1,715 ms
コンパイル使用メモリ 166,548 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-11 05:34:43
合計ジャッジ時間 2,718 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,380 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 5 ms
4,508 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 5 ms
4,380 KB
testcase_15 AC 6 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 5 ms
4,376 KB
testcase_21 AC 5 ms
4,376 KB
testcase_22 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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=100;
int main(){
    int p,q;
    cin>>p>>q;
    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