結果
| 問題 | 
                            No.65 回数の期待値の練習
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2014-11-13 23:31:04 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 516 bytes | 
| コンパイル時間 | 1,297 ms | 
| コンパイル使用メモリ | 159,872 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-12-31 10:17:21 | 
| 合計ジャッジ時間 | 2,368 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
#define RREP(i, n)          for(int(i)=(n)-1;(i)>=0;--(i))
double solve(int i){
    if(i <= 0) return 0.0;
    if(i == 1) return 1.0;
    double result = 0;
    for(int j = 1; j <= 6; j++){
        result += solve(i-j) * 1.0/6;
    }
    return result+1;
}
int main(){
    int N;
    cin >> N;
    cout << fixed << setprecision(9) << solve(N) << endl;
    return 0;
}