結果

問題 No.813 ユキちゃんの冒険
ユーザー sinsincoscossinsincoscos
提出日時 2019-04-12 23:09:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 613 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 70,252 KB
実行使用メモリ 35,256 KB
最終ジャッジ日時 2023-08-30 13:33:49
合計ジャッジ時間 2,296 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 7 ms
8,240 KB
testcase_02 AC 21 ms
17,988 KB
testcase_03 AC 20 ms
16,716 KB
testcase_04 AC 48 ms
35,104 KB
testcase_05 AC 45 ms
35,256 KB
testcase_06 AC 25 ms
21,180 KB
testcase_07 AC 11 ms
10,924 KB
testcase_08 AC 37 ms
29,508 KB
testcase_09 AC 9 ms
9,612 KB
testcase_10 AC 22 ms
18,836 KB
testcase_11 AC 17 ms
15,556 KB
testcase_12 AC 37 ms
29,524 KB
testcase_13 AC 27 ms
22,336 KB
testcase_14 AC 7 ms
8,192 KB
testcase_15 AC 44 ms
34,288 KB
testcase_16 AC 45 ms
35,256 KB
testcase_17 AC 12 ms
12,308 KB
testcase_18 AC 8 ms
9,304 KB
testcase_19 AC 45 ms
35,104 KB
testcase_20 AC 20 ms
16,944 KB
testcase_21 AC 12 ms
11,788 KB
testcase_22 AC 12 ms
11,912 KB
testcase_23 AC 28 ms
23,324 KB
testcase_24 AC 6 ms
7,660 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
using namespace std;

int N;
long double p,q;
long double dp[1010][1010][2];

int main(){
    cin >> N >> p >> q;
    dp[0][1][0] = 1;
    for(int i=0;i<=1000;i++){
        for(int j=1;j<N;j++){
            dp[i+1][j+1][0] += dp[i][j][0]*q;
            dp[i+1][j-1][1] += dp[i][j][0]*p;
        }
        for(int j=1;j<N;j++){
            dp[i+1][j-1][1] += dp[i][j][1]*q;
            dp[i+1][j+1][0] += dp[i][j][1]*p;
        }
    }
    long double ans = 0;
    for(int i=1;i<=1000;i++) ans += dp[i][0][1];
    cout << fixed;
    cout << setprecision(10) << ans << endl;
}
0