結果

問題 No.75 回数の期待値の問題
ユーザー kotatsugamekotatsugame
提出日時 2020-03-06 11:10:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,010 ms / 5,000 ms
コード長 277 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 03:48:11
合計ジャッジ時間 6,507 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
5,248 KB
testcase_01 AC 76 ms
5,376 KB
testcase_02 AC 89 ms
5,376 KB
testcase_03 AC 113 ms
5,376 KB
testcase_04 AC 85 ms
5,376 KB
testcase_05 AC 80 ms
5,376 KB
testcase_06 AC 69 ms
5,376 KB
testcase_07 AC 115 ms
5,376 KB
testcase_08 AC 114 ms
5,376 KB
testcase_09 AC 115 ms
5,376 KB
testcase_10 AC 117 ms
5,376 KB
testcase_11 AC 123 ms
5,376 KB
testcase_12 AC 131 ms
5,376 KB
testcase_13 AC 135 ms
5,376 KB
testcase_14 AC 136 ms
5,376 KB
testcase_15 AC 166 ms
5,376 KB
testcase_16 AC 474 ms
5,376 KB
testcase_17 AC 785 ms
5,376 KB
testcase_18 AC 941 ms
5,376 KB
testcase_19 AC 1,010 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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