結果

問題 No.813 ユキちゃんの冒険
ユーザー merom686merom686
提出日時 2019-04-12 23:11:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 755 bytes
コンパイル時間 832 ms
コンパイル使用メモリ 74,236 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-30 13:34:10
合計ジャッジ時間 1,876 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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[2][1002][2] = {};

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

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

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

    return 0;
}
0