結果
問題 | No.75 回数の期待値の問題 |
ユーザー |
![]() |
提出日時 | 2021-01-03 20:59:37 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,368 bytes |
コンパイル時間 | 1,599 ms |
コンパイル使用メモリ | 140,428 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 15:07:31 |
合計ジャッジ時間 | 113,390 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 4 |
other | TLE * 16 |
ソースコード
#include <cassert>#include <cmath>#include <algorithm>#include <iostream>#include <iomanip>#include <limits.h>#include <map>#include <queue>#include <set>#include <string.h>#include <vector>using namespace std;typedef long long ll;double TIME_LIMIT = 4.5;ll startCycle;const ll CYCLE_PER_SEC = 2700000000;unsigned long long int getCycle() {unsigned int low, high;__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));return ((unsigned long long int) low) | ((unsigned long long int) high << 32);}double getTime(unsigned long long int begin_cycle) {return (double) (getCycle() - begin_cycle) / CYCLE_PER_SEC;}unsigned long long xor128() {static unsigned long long rx = 123456789, ry = 362436069, rz = 521288629, rw = 88675123;unsigned long long rt = (rx ^ (rx << 11));rx = ry;ry = rz;rz = rw;return (rw = (rw ^ (rw >> 19)) ^ (rt ^ (rt >> 8)));}int main() {int K;cin >> K;startCycle = getCycle();ll loop_cnt = 0;ll sum = 0;double currentTime = getTime(startCycle);while (currentTime < TIME_LIMIT) {int n = 0;int cnt = 0;while (n < K) {n += (xor128() % 6) + 1;if (n > K) n = 0;++cnt;}++loop_cnt;sum += cnt;currentTime = getTime(startCycle);}cout << fixed << setprecision(10) << sum / (double) loop_cnt << endl;return 0;}