結果
問題 | No.76 回数の期待値で練習 |
ユーザー |
![]() |
提出日時 | 2018-11-27 20:51:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 5,000 ms |
コード長 | 876 bytes |
コンパイル時間 | 2,223 ms |
コンパイル使用メモリ | 195,052 KB |
最終ジャッジ日時 | 2025-01-06 17:45:14 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} struct Precision{ Precision(){ cout<<fixed<<setprecision(12); } }precision_beet; //INSERT ABOVE HERE signed main(){ const int MAX = 1e6+100; vector<double> dp(MAX); dp[1]=1.0000000000000000; dp[2]=1.0833333333333333; dp[3]=1.2569444444444444; dp[4]=1.5353009259259260; dp[5]=1.6915991512345676; dp[6]=2.0513639724794235; vector<double> p(7); p[1]=1.0/12; p[2]=2.0/12; p[3]=3.0/12; p[4]=1.0/12; p[5]=3.0/12; p[6]=2.0/12; for(int i=7;i<MAX;i++){ dp[i]=1; for(int j=1;j<=6;j++) dp[i]+=dp[i-j]*p[j]; } int t; cin>>t; while(t--){ int n; cin>>n; cout<<dp[n]<<endl; } return 0; }