結果

問題 No.813 ユキちゃんの冒険
ユーザー finefine
提出日時 2019-04-12 22:41:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 710 bytes
コンパイル時間 1,462 ms
コンパイル使用メモリ 166,864 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-30 13:30:05
合計ジャッジ時間 5,700 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	long double p, q;
	cin >> p >> q;
	q += p;

	int seed = 0;
	mt19937 mt(seed);
	uniform_real_distribution<long double> rnd(0, 1);
	int cnt = 0;
	const int LOOP_NUM = 2000000;
	for (int i = 0; i < LOOP_NUM; i++) {
		int cur = 1;
		int d = 1;
		while (true) {
			long double val = rnd(mt);
			if (val <= p) {
				d = -d;
				cur += d;
			} else if (val <= q) {
				cur += d;
			} else {
				break;
			}
			if (cur == n + 1) break;
			if (cur == 0) {
				cnt++;
				break;
			}
		}
	}
	cout << fixed << setprecision(15) << (double)cnt / LOOP_NUM << endl;
	return 0;
}
0