結果
問題 |
No.301 サイコロで確率問題 (1)
|
ユーザー |
|
提出日時 | 2020-03-07 05:38:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 38 ms / 1,000 ms |
コード長 | 445 bytes |
コンパイル時間 | 690 ms |
コンパイル使用メモリ | 70,364 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-14 11:13:07 |
合計ジャッジ時間 | 1,704 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~
ソースコード
#include<iostream> #include<iomanip> using namespace std; double a[101],b[101],ans[101]; main() { for(int i=99;i>=0;i--) { for(int j=1;j<=6;j++) { if(i+j>100)a[i]+=1./6; else if(i+j<100) { a[i]+=a[i+j]/6; b[i]+=b[i+j]/6; } } b[i]+=1; } for(int i=1;i<=100;i++) { ans[i]=b[100-i]/(1-a[100-i]); } int T;cin>>T; for(;T--;) { long N;cin>>N; cout<<fixed<<setprecision(16)<<(N<=100?ans[N]:N+5/3.)<<endl; } }