結果

問題 No.813 ユキちゃんの冒険
ユーザー 👑 emthrmemthrm
提出日時 2019-04-12 22:51:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,633 bytes
コンパイル時間 1,177 ms
コンパイル使用メモリ 120,480 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 13:31:02
合計ジャッジ時間 2,699 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int n;
double ans = 0, p, q;
void calc(int pos, bool right, double now) {
  if (now < EPS) return;
  if (right) {
    if (pos == 1) {
      ans += now * p;
      calc(pos + 1, true, now * q);
    } else if (pos == n) {
      calc(pos - 1, false, now * p);
    } else {
      calc(pos - 1, false, now * p);
      calc(pos + 1, true, now * q);
    }
  } else {
    if (pos == 1) {
      ans += now * q;
      calc(pos + 1, true, now * p);
    } else if (pos == n) {
      calc(pos - 1, false, now * q);
    } else {
      calc(pos - 1, false, now * q);
      calc(pos + 1, true, now * p);
    }
  }
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  cin >> n >> p >> q;
  calc(1, true, 1);
  printf("%.7f\n", ans);
  return 0;
}
0