結果

問題 No.813 ユキちゃんの冒険
ユーザー veqccveqcc
提出日時 2019-04-12 23:08:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 793 bytes
コンパイル時間 842 ms
コンパイル使用メモリ 99,796 KB
実行使用メモリ 19,336 KB
最終ジャッジ日時 2023-08-30 13:32:12
合計ジャッジ時間 2,418 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 4 ms
8,788 KB
testcase_03 WA -
testcase_04 AC 15 ms
19,336 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 4 ms
9,056 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 5 ms
11,252 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 12 ms
17,888 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef long double ld;
using namespace std;

ld dp[1005][1005];
// i->j->iとなる確率

int main() {
    int n;
    ld p, q;
    cin >> n >> p >> q;

    if (q == 0.0) {
        cout << p << "\n";
        return 0;
    }

    for (int i = 0; i < n-1; i++) dp[i][i+1] = p;
    for (int d = 2; d < n; d++) {
        for (int i = 0; i < n; i++)  {
            dp[i][i+d] = q * q * dp[i+1][i+d] / (1.0 - p);
        }
    }

    ld ans = p;
    for (int i = 1; i < n; i++) ans += q * q * dp[0][i];

    cout << ans << "\n";
    return 0;
}
0