結果

問題 No.813 ユキちゃんの冒険
ユーザー pekempeypekempey
提出日時 2019-04-14 16:55:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 724 bytes
コンパイル時間 869 ms
コンパイル使用メモリ 74,424 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-30 15:14:30
合計ジャッジ時間 2,648 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,376 KB
testcase_01 AC 7 ms
4,380 KB
testcase_02 AC 11 ms
4,380 KB
testcase_03 AC 10 ms
4,380 KB
testcase_04 AC 20 ms
4,380 KB
testcase_05 AC 27 ms
4,380 KB
testcase_06 AC 17 ms
4,380 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 90 ms
4,376 KB
testcase_09 AC 7 ms
4,380 KB
testcase_10 AC 13 ms
4,380 KB
testcase_11 AC 10 ms
4,384 KB
testcase_12 AC 51 ms
4,380 KB
testcase_13 AC 14 ms
4,380 KB
testcase_14 AC 6 ms
4,380 KB
testcase_15 AC 82 ms
4,376 KB
testcase_16 AC 19 ms
4,376 KB
testcase_17 AC 8 ms
4,380 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 86 ms
4,380 KB
testcase_20 AC 10 ms
4,500 KB
testcase_21 AC 8 ms
4,380 KB
testcase_22 AC 8 ms
4,384 KB
testcase_23 AC 145 ms
4,380 KB
testcase_24 AC 6 ms
4,380 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <cstring>

using namespace std;

int N;
double P, Q;
double dp0[1000][2];
double dp1[1000][2];

int main() {
  cin >> N >> P >> Q;
  dp0[0][0] = 1;
  double ans = 0;
  for (int ii = 0; ii < 5000; ii++) {
    memset(dp1, 0, sizeof(dp1));
    for (int i = 0; i + 1 < N; i++) {
      dp1[i + 1][0] += dp0[i][0] * Q;
    }
    for (int i = 0; i + 1 < N; i++) {
      dp1[i][1] += dp0[i + 1][1] * Q;
    }
    for (int i = 0; i < N; i++) {
      dp1[i][1] += dp0[i][0] * P;
    }
    for (int i = 1; i < N; i++) {
      dp1[i][0] += dp0[i][1] * P;
    }
    swap(dp0, dp1);
    ans += dp0[0][1];
  }
  printf("%.15f\n", ans);
}
0