結果
| 問題 |
No.75 回数の期待値の問題
|
| ユーザー |
myanta
|
| 提出日時 | 2017-05-29 23:48:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 723 bytes |
| コンパイル時間 | 604 ms |
| コンパイル使用メモリ | 41,600 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2024-09-21 18:15:21 |
| 合計ジャッジ時間 | 1,396 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 WA * 2 |
ソースコード
#include<cstdio>
#include<vector>
using namespace std;
using pid=pair<int,double>;
using vd=vector<long double>;
using vvd=vector<vd>;
int main(void)
{
int k, i, j, l, n;
vvd c;
long double r=1.0/6, ans;
while(scanf("%d", &k)==1)
{
c.resize(1000);
for(auto&ce:c) ce.assign(k+1, 0.0);
c[0][0]=1.0;
for(i=1;i<c.size();i++)
{
for(j=0;j<k;j++)
{
for(l=1;l<=6;l++)
{
n=j+l;
if(n>k) n=0;
c[i][n]+=c[i-1][j]*r;
}
}
}
/*
printf("--- dump start ---\n");
for(auto&ce:c)
{
for(auto cee:ce) printf("%.3f ", cee);
printf("\n");
}
printf("--- dump end ---\n");
*/
ans=0.0;
for(i=1;i<c.size();i++)
{
ans+=i*c[i][k];
}
printf("%f\n" ,(double)ans);
}
return 0;
}
myanta