結果

問題 No.75 回数の期待値の問題
ユーザー cielciel
提出日時 2014-11-24 23:20:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,191 ms / 5,000 ms
コード長 589 bytes
コンパイル時間 1,336 ms
コンパイル使用メモリ 62,992 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 22:44:35
合計ジャッジ時間 6,679 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
4,380 KB
testcase_01 AC 46 ms
4,380 KB
testcase_02 AC 49 ms
4,380 KB
testcase_03 AC 72 ms
4,376 KB
testcase_04 AC 48 ms
4,376 KB
testcase_05 AC 46 ms
4,376 KB
testcase_06 AC 45 ms
4,376 KB
testcase_07 AC 74 ms
4,376 KB
testcase_08 AC 77 ms
4,376 KB
testcase_09 AC 81 ms
4,376 KB
testcase_10 AC 85 ms
4,380 KB
testcase_11 AC 92 ms
4,380 KB
testcase_12 AC 103 ms
4,380 KB
testcase_13 AC 106 ms
4,376 KB
testcase_14 AC 112 ms
4,376 KB
testcase_15 AC 141 ms
4,380 KB
testcase_16 AC 519 ms
4,380 KB
testcase_17 AC 919 ms
4,376 KB
testcase_18 AC 1,107 ms
4,376 KB
testcase_19 AC 1,191 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <random>
#include <cstdio>
#include <ctime>
#include <unistd.h>
using namespace std;

double expected(int n, int s, int t){//vector<int> b){
	int T=200000;
	int S=0;
	uniform_int_distribution<int> distribution(1,s);
	mt19937_64 engine((unsigned int)time(NULL)^(getpid()<<16));
	for(int I=0;I<T;I++){
		int turn=0;
		int cur=0;
		for(;cur!=t;){
			for(int i=0;i<n;i++)cur+=distribution(engine);
			if(cur>t)cur=0;
			turn++;
		}
		S+=turn;
	}
	return S*1.0/T;
}

int main(){
	int N;
	scanf("%d",&N);
	printf("%f\n",expected(1,6,N));
}
0