結果

問題 No.75 回数の期待値の問題
ユーザー kotatsugame
提出日時 2020-03-06 11:10:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,960 ms / 5,000 ms
コード長 277 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 81,288 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-14 02:41:32
合計ジャッジ時間 10,384 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<random>
using namespace std;
int K;
main()
{
	cin>>K;
	mt19937 rng(114514);
	int sum=0;
	for(int c=0;c<1000000;c++)
	{
		int cnt=0,now=0;
		while(now!=K)
		{
			now+=rng()%6+1;
			cnt++;
			if(now>K)now=0;
		}
		sum+=cnt;
	}
	cout<<sum/1e6<<endl;
}
0