結果
問題 | No.75 回数の期待値の問題 |
ユーザー |
![]() |
提出日時 | 2014-11-23 23:57:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4,751 ms / 5,000 ms |
コード長 | 1,010 bytes |
コンパイル時間 | 711 ms |
コンパイル使用メモリ | 68,708 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-02 20:51:57 |
合計ジャッジ時間 | 100,598 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include <iostream>#include <algorithm>#include <vector>#include <cmath>using namespace std;#define loop(i,a,b) for(int i=(a);i<int(b);i++)#define rep(i,b) loop(i,0,b)int main(){int K;while(cin>>K){double dp[2][222];rep(j,2)rep(i,222)dp[j][i]=0;dp[0][0]=1;double ans=0;clock_t start = clock();for(int t=1;;t++){rep(i,K+1)dp[(t&1)][i]=0;for(int i=0;i<K;i++){for(int j=1;j<=6;j++){if(i+j>K) dp[(t&1)][0] +=dp[1-(t&1)][i]/6;else dp[(t&1)][i+j]+=dp[1-(t&1)][i]/6;}}// for(int i=0;i<=10;i++){// cout << dp[1-(t&1)][i] << " ";// }// cout << endl;ans+=dp[1-(t&1)][K]*t;clock_t end = clock();if((double)(end-start)/CLOCKS_PER_SEC > 4.5)break;}printf("%.20lf\n",ans-1);}}