結果
問題 | No.76 回数の期待値で練習 |
ユーザー |
|
提出日時 | 2023-02-21 16:51:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 5,000 ms |
コード長 | 1,039 bytes |
コンパイル時間 | 912 ms |
コンパイル使用メモリ | 80,216 KB |
最終ジャッジ日時 | 2025-02-10 19:44:49 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 |
ソースコード
#include<iostream> #include<vector> #include<iomanip> using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i<n;i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} vector<double>e= { 1.0000000000000000, 1.0833333333333333, 1.2569444444444444, 1.5353009259259260, 1.6915991512345676, 2.0513639724794235 }; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout<<fixed<<setprecision(12); vector<double>p(6); rep(i,5){ p[i]=e[i+1]-1; rep(j,i)p[i]-=p[j]*e[i-j]; } p[5]=1; rep(i,5)p[5]-=p[i]; for(int i=6;i<1e6;i++){ double b=1; rep(j,6)b+=p[j]*e[i-1-j]; e.push_back(b); } int t; cin>>t; while(t--){ int n; cin>>n; n--; cout<<e[n]<<"\n"; } }