結果
| 問題 | 
                            No.65 回数の期待値の練習
                             | 
                    
| コンテスト | |
| ユーザー | 
                             oxyshower
                         | 
                    
| 提出日時 | 2020-01-20 20:34:39 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 451 bytes | 
| コンパイル時間 | 1,741 ms | 
| コンパイル使用メモリ | 169,108 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-02 23:01:14 | 
| 合計ジャッジ時間 | 2,211 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
signed main(){
  int k; cin >> k;
  vector<double> dp(30, -1);
  dp[0] = 0;
  function< double(int) > rec =
  [&](int x){
    if(dp[x] != -1) return dp[x];
    dp[x] = 1;
    for(int j = 1; j <= 6; j++){
      if(x - j >= 0) dp[x] += rec(x - j) * 1.0 / 6;
    }
    return dp[x];
  };
  cout << rec(k) << endl;
  return 0;
}
            
            
            
        
            
oxyshower