結果
| 問題 | No.75 回数の期待値の問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-09 18:33:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,953 ms / 5,000 ms |
| コード長 | 815 bytes |
| コンパイル時間 | 1,528 ms |
| コンパイル使用メモリ | 166,856 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 13:01:52 |
| 合計ジャッジ時間 | 43,436 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
random_device rnd;
unsigned simulation(const int& K) {
int cnt = 0, sum = 0;
while (sum != K) {
sum += rnd() % 6 + 1;
if (sum > K) {
sum = 0;
}
cnt++;
}
return cnt;
}
int main() {
chrono::system_clock::time_point start, end;
start = chrono::system_clock::now();
int K;
cin >> K;
unsigned counter = 0;
unsigned long long sum = 0;
while (true) {
end = chrono::system_clock::now();
double time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0);
if (time > 1950) {
break;
}
counter++;
sum += simulation(K);
}
cout << (long double)sum / (long double)counter << endl;
}