結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,500 KB
testcase_01 WA -
testcase_02 AC 32 ms
8,872 KB
testcase_03 WA -
testcase_04 AC 821 ms
19,268 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 40 ms
8,960 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 86 ms
11,228 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 582 ms
17,840 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
4,380 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; i++) dp[i][i] = p / (q * q);
    for (int d = 1; d < n; d++) {
        for (int i = 0; i < n; i++)  {
            ld tmp = 0.0;
            for (int k = i + 1; k < i + d; k++) tmp += q * q * dp[i+1][k];
            dp[i][i+d] = q * q * dp[i+1][i+d] / (1.0 - tmp);
        }
    }

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

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