結果
| 問題 | No.75 回数の期待値の問題 |
| コンテスト | |
| ユーザー |
ninoinui
|
| 提出日時 | 2020-09-26 05:41:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 786 ms / 5,000 ms |
| コード長 | 647 bytes |
| コンパイル時間 | 1,794 ms |
| コンパイル使用メモリ | 194,912 KB |
| 最終ジャッジ日時 | 2025-01-14 21:54:41 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U> void cmin(T &a, U b) {
if (a > b) a = b;
}
template <typename T, typename U> void cmax(T &a, U b) {
if (a < b) a = b;
}
signed main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
random_device rd;
mt19937 mt(rd());
long K;
cin >> K;
long ans = 0;
for (long i = 1e6; i; i--) {
long sum = 0, cnt = 0;
while (true) {
sum += mt() % 6 + 1, cnt++;
if (sum == K) {
ans += cnt;
break;
} else {
if (sum > K) sum = 0;
}
}
}
cout << fixed << setprecision(3) << ans / 1e6 << "\n";
}
ninoinui