結果

問題 No.813 ユキちゃんの冒険
ユーザー chocoruskchocorusk
提出日時 2019-04-13 00:44:32
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,019 bytes
コンパイル時間 2,098 ms
コンパイル使用メモリ 96,200 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-08-30 13:50:07
合計ジャッジ時間 6,569 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; double p, q; cin>>n>>p>>q;
    double ans=0;
    double dp[2][2][1003]={};
    dp[0][0][1]=1;
    for(int i=1; i<=200000; i++){
        fill(dp[0][i&1], dp[0][i&1]+n+2, 0);
        fill(dp[1][i&1], dp[1][i&1]+n+2, 0);
        for(int j=1; j<=n; j++){
                dp[1][i&1][j-1]+=p*dp[0][(i&1)^1][j];
                dp[0][i&1][j+1]+=q*dp[0][(i&1)^1][j];
                dp[1][i&1][j-1]+=q*dp[1][(i&1)^1][j];
                dp[0][i&1][j+1]+=p*dp[1][(i&1)^1][j];
        }
        ans+=dp[1][i&1][0];
    }
    cout<<ans<<endl;
    return 0;
}
0