結果
| 問題 | No.75 回数の期待値の問題 |
| コンテスト | |
| ユーザー |
Ysmr_Ry
|
| 提出日時 | 2014-11-24 18:48:21 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 4,109 ms / 5,000 ms |
| コード長 | 764 bytes |
| 記録 | |
| コンパイル時間 | 362 ms |
| コンパイル使用メモリ | 62,720 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-06 07:45:50 |
| 合計ジャッジ時間 | 86,261 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include<cstdio>
#include<ctime>
#include<map>
unsigned int xor128()
{
static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
unsigned int t = x^(x<<11);
x = y; y = z; z = w;
return w=(w^w>>19)^(t^(t>>8));
}
std::map<int, int> m;
int main()
{
int K;
scanf( "%d", &K );
clock_t t = clock();
int total = 0;
while( clock() <= t+4*CLOCKS_PER_SEC )
{
int sum = 0, cnt = 0;
for(;;)
{
int n = xor128()%6+1;
sum += n;
++cnt;
if( sum == K )
break;
if( sum > K )
sum = 0;
}
++m[cnt];
++total;
}
double ans = 0;
for( auto it = m.begin(); it != m.end(); ++it )
ans += (double)it->first*it->second/total;
printf( "%.2f\n", ans );
return 0;
}
Ysmr_Ry