結果

問題 No.75 回数の期待値の問題
ユーザー koyoprokoyopro
提出日時 2015-10-01 15:45:55
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 525 bytes
コンパイル時間 1,312 ms
コンパイル使用メモリ 143,364 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 01:12:51
合計ジャッジ時間 31,898 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 845 ms
4,380 KB
testcase_01 AC 836 ms
4,376 KB
testcase_02 AC 840 ms
4,376 KB
testcase_03 AC 1,328 ms
4,380 KB
testcase_04 AC 847 ms
4,380 KB
testcase_05 AC 841 ms
4,380 KB
testcase_06 AC 846 ms
4,380 KB
testcase_07 AC 1,368 ms
4,376 KB
testcase_08 AC 1,423 ms
4,376 KB
testcase_09 AC 1,492 ms
4,376 KB
testcase_10 AC 1,631 ms
4,376 KB
testcase_11 AC 1,723 ms
4,376 KB
testcase_12 AC 1,916 ms
4,380 KB
testcase_13 AC 2,005 ms
4,376 KB
testcase_14 AC 2,095 ms
4,376 KB
testcase_15 AC 2,678 ms
4,380 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

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