結果
| 問題 |
No.75 回数の期待値の問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-04 08:40:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 477 bytes |
| コンパイル時間 | 4,116 ms |
| コンパイル使用メモリ | 250,332 KB |
| 最終ジャッジ日時 | 2025-01-29 02:17:16 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
int n;
double dpa[202],dpb[202];
void solve(){
for(int i = n-1;i>=0;i--){
for(int j = 1;j<=6;j++){
if(i+j>n){
dpa[i] += 1/6.0;
}else{
dpa[i] += dpa[i+j]/6.0;
dpb[i] += dpb[i+j]/6.0;
}
}
dpb[i] += 1;
}
printf("%.10lf\n",dpb[0]/(1.0-dpa[0]));
}
signed main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin >> n;
solve();
}