結果
問題 | No.75 回数の期待値の問題 |
ユーザー |
|
提出日時 | 2016-07-08 00:28:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 5,000 ms |
コード長 | 838 bytes |
コンパイル時間 | 1,378 ms |
コンパイル使用メモリ | 165,928 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 23:22:34 |
合計ジャッジ時間 | 2,204 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr) #define all(x) (x).begin(),(x).end() #define mp make_pair #define pb push_back #define fi first #define se second const int N=10000; int main() { int k; cin >>k; double ans=0; double dp[201]={0}; dp[0]=1; for(int i=1; i<N; ++i) { double newdp[201]={0}; rep(j,k) { for(int x=1; x<=6; ++x) { if(j+x<=k) newdp[j+x]+=dp[j]/6; else newdp[0]+=dp[j]/6; } } ans+=i*newdp[k]; //printf("%d : %lf\n", i,newdp[k]); rep(j,k+1) dp[j]=newdp[j]; } printf("%.10lf\n", ans); return 0; }