結果
問題 | No.813 ユキちゃんの冒険 |
ユーザー |
|
提出日時 | 2019-04-12 22:40:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 710 bytes |
コンパイル時間 | 1,693 ms |
コンパイル使用メモリ | 163,996 KB |
実行使用メモリ | 13,768 KB |
最終ジャッジ日時 | 2025-01-02 03:30:56 |
合計ジャッジ時間 | 20,469 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 TLE * 4 |
ソースコード
#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 = 5000000;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;}