結果

問題 No.813 ユキちゃんの冒険
ユーザー finefine
提出日時 2019-04-12 22:37:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 708 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 167,164 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 13:28:14
合計ジャッジ時間 5,740 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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