結果

問題 No.425 ジャンケンの必勝法
ユーザー btkbtk
提出日時 2016-09-22 15:07:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 341 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 1,405 ms
コンパイル使用メモリ 166,764 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 05:33:57
合計ジャッジ時間 10,449 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 336 ms
4,380 KB
testcase_01 AC 332 ms
4,380 KB
testcase_02 AC 332 ms
4,376 KB
testcase_03 AC 333 ms
4,380 KB
testcase_04 AC 332 ms
4,380 KB
testcase_05 AC 337 ms
4,380 KB
testcase_06 AC 332 ms
4,376 KB
testcase_07 AC 334 ms
4,380 KB
testcase_08 AC 333 ms
4,380 KB
testcase_09 AC 332 ms
4,380 KB
testcase_10 AC 331 ms
4,376 KB
testcase_11 AC 337 ms
4,376 KB
testcase_12 AC 339 ms
4,380 KB
testcase_13 AC 340 ms
4,376 KB
testcase_14 AC 341 ms
4,380 KB
testcase_15 AC 337 ms
4,380 KB
testcase_16 AC 336 ms
4,380 KB
testcase_17 AC 338 ms
4,376 KB
testcase_18 AC 326 ms
4,376 KB
testcase_19 AC 328 ms
4,376 KB
testcase_20 AC 338 ms
4,380 KB
testcase_21 AC 333 ms
4,380 KB
testcase_22 AC 338 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=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