結果
問題 | No.75 回数の期待値の問題 |
ユーザー |
![]() |
提出日時 | 2015-10-01 15:46:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4,099 ms / 5,000 ms |
コード長 | 525 bytes |
コンパイル時間 | 1,377 ms |
コンパイル使用メモリ | 157,412 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 18:53:31 |
合計ジャッジ時間 | 19,089 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(int i=0; i<(n); i++) int K; signed main() { cin >> K; double ret = 0; int trynum = 1e6; REP(i,trynum) { int s = 0; int cnt = 0; while(true) { s += 1 + rand() % 6; cnt++; if (s == K) { ret += 1.0 * cnt / trynum; break; } else if (s > K) { s = 0; } } } printf("%.14f\n", ret); return 0; }