結果

問題 No.813 ユキちゃんの冒険
ユーザー mamekinmamekin
提出日時 2019-04-15 23:19:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,248 bytes
コンパイル時間 3,375 ms
コンパイル使用メモリ 118,136 KB
実行使用メモリ 10,040 KB
最終ジャッジ日時 2023-08-30 15:16:19
合計ジャッジ時間 12,191 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
8,528 KB
testcase_01 AC 11 ms
4,380 KB
testcase_02 AC 64 ms
4,384 KB
testcase_03 AC 57 ms
4,380 KB
testcase_04 AC 320 ms
4,380 KB
testcase_05 TLE -
testcase_06 AC 83 ms
4,376 KB
testcase_07 AC 514 ms
4,380 KB
testcase_08 AC 1,841 ms
4,376 KB
testcase_09 AC 17 ms
4,380 KB
testcase_10 AC 69 ms
4,380 KB
testcase_11 AC 50 ms
4,384 KB
testcase_12 AC 157 ms
4,376 KB
testcase_13 AC 87 ms
4,384 KB
testcase_14 AC 9 ms
4,380 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

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<50000; ++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