結果
問題 |
No.75 回数の期待値の問題
|
ユーザー |
![]() |
提出日時 | 2016-04-30 17:24:07 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2,089 ms / 5,000 ms |
コード長 | 684 bytes |
コンパイル時間 | 587 ms |
コンパイル使用メモリ | 74,140 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-05 00:10:21 |
合計ジャッジ時間 | 10,650 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <random> using namespace std; #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP(i,n-1,0) #define REP(i,s,e) for (i = s; i < e; i++) #define rep(i,n) REP(i,0,n) #define INF 100000000 typedef long long ll; int main() { int i, k; double ans = 0; default_random_engine e; uniform_int_distribution<int> u{1,6}; cin >> k; rep (i,500000) { int x = 0; int cnt = 0; while (x != k) { x += u(e); if (x > k) x = 0; cnt++; } ans += cnt; } cout << ans / 500000 << endl; return 0; }