結果

問題 No.75 回数の期待値の問題
ユーザー koyopro
提出日時 2015-10-01 15:45:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 525 bytes
コンパイル時間 1,249 ms
コンパイル使用メモリ 157,628 KB
実行使用メモリ 14,016 KB
最終ジャッジ日時 2024-07-19 18:53:06
合計ジャッジ時間 44,693 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 TLE * 1 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 = 1e7;
    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;
}
0