結果

問題 No.813 ユキちゃんの冒険
ユーザー merom686merom686
提出日時 2019-04-14 10:31:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 921 ms / 2,000 ms
コード長 639 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 73,932 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 07:21:52
合計ジャッジ時間 6,867 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 6 ms
4,348 KB
testcase_02 AC 387 ms
4,348 KB
testcase_03 AC 83 ms
4,348 KB
testcase_04 AC 273 ms
4,348 KB
testcase_05 AC 786 ms
4,348 KB
testcase_06 AC 126 ms
4,348 KB
testcase_07 AC 31 ms
4,348 KB
testcase_08 AC 517 ms
4,348 KB
testcase_09 AC 19 ms
4,348 KB
testcase_10 AC 96 ms
4,348 KB
testcase_11 AC 72 ms
4,348 KB
testcase_12 AC 194 ms
4,348 KB
testcase_13 AC 386 ms
4,348 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 921 ms
4,348 KB
testcase_16 AC 632 ms
4,348 KB
testcase_17 AC 45 ms
4,348 KB
testcase_18 AC 15 ms
4,348 KB
testcase_19 AC 288 ms
4,348 KB
testcase_20 AC 89 ms
4,348 KB
testcase_21 AC 41 ms
4,348 KB
testcase_22 AC 41 ms
4,348 KB
testcase_23 AC 138 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 279 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;

    double p, q;
    cin >> p >> q;

    double x[1002][2] = {};

    x[0][0] = 1;
    x[n + 1][1] = 0;
    for (int i = 1; i <= n; i++) {
        x[i][0] = 0.5;
    }

    for (int h = 0; h < 100000; h++) {
        for (int i = 1; i <= n; i++) {
            x[i][0] = q * x[i - 1][0] + p * x[i + 1][1];
            x[i][1] = p * x[i - 1][0] + q * x[i + 1][1];
        }
    }

    printf("%.8f\n", x[1][1]);

    return 0;
}
0