結果
| 問題 | 
                            No.65 回数の期待値の練習
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ferin
                         | 
                    
| 提出日時 | 2017-02-01 23:35:48 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 678 bytes | 
| コンパイル時間 | 1,768 ms | 
| コンパイル使用メモリ | 166,192 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-24 02:22:09 | 
| 合計ジャッジ時間 | 2,616 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12
int main(void)
{
  int k;
  cin >> k;
  double e[30];
  e[k-1] = 1;
  FOR(i, k, k+5) e[i] = 0;
  for(int i=k-2; i>=0; i--) {
    e[i] = (e[i+1] + e[i+2] + e[i+3] + e[i+4] + e[i+5] + e[i+6])/6 + 1;
  }
  cout << fixed << setprecision(8) << e[0] << endl;
  return 0;
}
            
            
            
        
            
ferin