結果
| 問題 |
No.75 回数の期待値の問題
|
| コンテスト | |
| ユーザー |
11/23
|
| 提出日時 | 2014-11-23 23:36:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 89 ms / 5,000 ms |
| コード長 | 563 bytes |
| コンパイル時間 | 598 ms |
| コンパイル使用メモリ | 63,812 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-02 20:33:01 |
| 合計ジャッジ時間 | 1,907 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
using namespace std;
int main()
{
int k; cin >>k;
double p[2][220]={}, res=0;
p[0][0]=1.0;
rep(i,50000){
int cur=i&1, nxt=cur^1;
rep(j,220) p[nxt][j]=0.0;
rep(j,k) rep(s,6){
if(j+ s+1 <=k) p[nxt][j+s+1] += p[cur][j] /6.0;
else p[nxt][0] += p[cur][j] /6.0;
}
res += (i+1) * p[nxt][k];
}
printf("%.10f", res);
return 0;
}
11/23