結果
| 問題 |
No.813 ユキちゃんの冒険
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-13 00:33:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,104 bytes |
| コンパイル時間 | 1,700 ms |
| コンパイル使用メモリ | 164,488 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-02 04:00:40 |
| 合計ジャッジ時間 | 65,110 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr double ticks_per_sec = 2800000000;
constexpr double ticks_per_sec_inv = 1.0 / ticks_per_sec;
inline double rdtsc() { // in seconds
uint32_t lo, hi;
asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
return (((uint64_t)hi << 32) | lo) * ticks_per_sec_inv;
}
constexpr double TLE = 2; // sec
int main() {
double clock_begin = rdtsc();
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);
ll cnt = 0;
double clock_end = clock_begin + TLE * 0.95;
ll loop_cnt = 0;
while (rdtsc() < clock_end) {
loop_cnt++;
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_cnt << endl;
return 0;
}