結果
| 問題 | No.75 回数の期待値の問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-18 23:46:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1,546 ms / 5,000 ms |
| コード長 | 577 bytes |
| コンパイル時間 | 673 ms |
| コンパイル使用メモリ | 74,124 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-23 21:16:27 |
| 合計ジャッジ時間 | 31,309 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <random>
using namespace std;
const int MAX_ROLL = 1e8;
int main() {
int k;
cin >> k;
int seed = 0;
mt19937 mt(seed);
uniform_int_distribution<> dice(1, 6);
int sum = 0;
int start = 0;
long long success = 0;
for (int i = 0; i < MAX_ROLL; i++) {
sum += dice(mt);
if (sum == k) {
success++;
sum = 0;
} else if (sum > k) {
sum = 0;
}
}
double ans = success != 0 ? 1.0 * MAX_ROLL / success : MAX_ROLL;
printf("%.6f\n", ans);
return 0;
}