結果

問題 No.813 ユキちゃんの冒険
ユーザー mamekinmamekin
提出日時 2019-04-15 23:20:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,248 bytes
コンパイル時間 1,244 ms
コンパイル使用メモリ 120,600 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-30 15:16:05
合計ジャッジ時間 4,416 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 4 ms
4,380 KB
testcase_02 AC 15 ms
4,380 KB
testcase_03 AC 13 ms
4,384 KB
testcase_04 AC 36 ms
4,380 KB
testcase_05 AC 57 ms
4,384 KB
testcase_06 AC 22 ms
4,380 KB
testcase_07 AC 48 ms
4,384 KB
testcase_08 AC 285 ms
4,384 KB
testcase_09 AC 5 ms
4,384 KB
testcase_10 AC 17 ms
4,380 KB
testcase_11 AC 11 ms
4,384 KB
testcase_12 AC 62 ms
4,380 KB
testcase_13 AC 20 ms
4,384 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 486 ms
4,384 KB
testcase_16 AC 32 ms
4,380 KB
testcase_17 AC 40 ms
4,380 KB
testcase_18 AC 4 ms
4,384 KB
testcase_19 AC 103 ms
4,384 KB
testcase_20 AC 27 ms
4,384 KB
testcase_21 AC 17 ms
4,380 KB
testcase_22 AC 9 ms
4,380 KB
testcase_23 AC 429 ms
4,380 KB
testcase_24 AC 3 ms
4,384 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int RIGHT = 0;
const int LEFT  = 1;

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

    vector<vector<double> > dp(2, vector<double>(n+2, 0.0));
    dp[RIGHT][1] = 1.0;
    double ans = 0.0;
    for(int i=0; i<10000; ++i){
        vector<vector<double> > nextDp(2, vector<double>(n+2, 0.0));
        for(int j=1; j<=n; ++j){
            nextDp[LEFT][j-1]  += dp[RIGHT][j] * p;
            nextDp[RIGHT][j+1] += dp[LEFT][j]  * p;
            nextDp[RIGHT][j+1] += dp[RIGHT][j] * q;
            nextDp[LEFT][j-1]  += dp[LEFT][j]  * q;
        }
        dp = move(nextDp);
        ans += dp[LEFT][0];
    }

    cout.setf(ios_base::fixed, ios_base::floatfield);
    cout << setprecision(10) << ans << endl;

    return 0;
}
0