結果

問題 No.813 ユキちゃんの冒険
ユーザー koyoprokoyopro
提出日時 2020-02-28 00:06:37
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,502 bytes
コンパイル時間 1,282 ms
コンパイル使用メモリ 144,124 KB
実行使用メモリ 13,728 KB
最終ジャッジ日時 2023-08-30 15:41:33
合計ジャッジ時間 18,821 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,808 KB
testcase_01 AC 7 ms
8,208 KB
testcase_02 AC 208 ms
10,436 KB
testcase_03 AC 179 ms
10,120 KB
testcase_04 AC 1,336 ms
13,380 KB
testcase_05 AC 1,746 ms
13,688 KB
testcase_06 AC 598 ms
11,220 KB
testcase_07 AC 20 ms
8,712 KB
testcase_08 AC 1,091 ms
13,552 KB
testcase_09 AC 12 ms
8,340 KB
testcase_10 AC 295 ms
10,732 KB
testcase_11 AC 87 ms
10,072 KB
testcase_12 AC 1,145 ms
13,320 KB
testcase_13 AC 505 ms
11,496 KB
testcase_14 AC 7 ms
7,952 KB
testcase_15 TLE -
testcase_16 AC 1,571 ms
13,700 KB
testcase_17 AC 34 ms
9,076 KB
testcase_18 AC 12 ms
8,304 KB
testcase_19 TLE -
testcase_20 AC 253 ms
10,184 KB
testcase_21 AC 29 ms
9,140 KB
testcase_22 AC 29 ms
9,116 KB
testcase_23 AC 629 ms
11,968 KB
testcase_24 AC 6 ms
7,604 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 1230
#else
#define SIZE 1230
#endif

int N;
double p,q;
// i回目の逃走でj番目の門で折り返しす場合の確率
double DP[1010][SIZE];
int I=1000;

void solve() {
    cin>>N>>p>>q;
    
    REP1(j,N) {
        DP[0][j] = pow(q, j-1) * p;
    }
    REP1(i,I)REP1(j,N) {
        double base = p;
        RREP1(k,j-1) {
            if (i%2) {
                DP[i][k] += DP[i-1][j] * base;
            } else {
                DP[i][j] += DP[i-1][k] * base;
            }
            base *= q;
        }
        if (i%2) {
            DP[i][0] += DP[i-1][j] * base / p;
        }
    }
    double ans = 0;
    REP1(i,I) ans += DP[i][0];
    out("%.14f\n", ans);
}
0