結果

問題 No.65 回数の期待値の練習
ユーザー tkzw_21tkzw_21
提出日時 2015-03-18 16:11:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 406 bytes
コンパイル時間 1,107 ms
コンパイル使用メモリ 144,296 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 08:33:06
合計ジャッジ時間 3,268 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
4,384 KB
testcase_01 AC 17 ms
4,376 KB
testcase_02 AC 23 ms
4,376 KB
testcase_03 AC 37 ms
4,380 KB
testcase_04 AC 28 ms
4,376 KB
testcase_05 AC 29 ms
4,376 KB
testcase_06 AC 32 ms
4,376 KB
testcase_07 AC 40 ms
4,376 KB
testcase_08 AC 43 ms
4,376 KB
testcase_09 AC 46 ms
4,380 KB
testcase_10 AC 50 ms
4,376 KB
testcase_11 AC 53 ms
4,376 KB
testcase_12 AC 57 ms
4,376 KB
testcase_13 AC 60 ms
4,376 KB
testcase_14 AC 62 ms
4,380 KB
testcase_15 AC 65 ms
4,380 KB
testcase_16 AC 68 ms
4,380 KB
testcase_17 AC 71 ms
4,380 KB
testcase_18 AC 75 ms
4,376 KB
testcase_19 AC 78 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//weekly CD
//https://www.hackerrank.com/contests/w14/challenges
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int func(int k){
	int sum = 0,cnt = 0;
	while(sum < k){
		sum += rand()%6+1;
		cnt++;
	}
	return cnt;
}

int main(void) {
	int k;
	cin >> k;

	ll sum = 0;
	for(int i=0;i<1e6;i++){
		sum += func(k);
	}
	cout << fixed << setprecision(5) << 1.*sum/1e6 << endl;
	return 0;
}

0