結果

問題 No.76 回数の期待値で練習
ユーザー hashiryohashiryo
提出日時 2019-05-20 13:22:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 656 ms / 5,000 ms
コード長 1,255 bytes
コンパイル時間 795 ms
コンパイル使用メモリ 96,748 KB
実行使用メモリ 11,624 KB
最終ジャッジ日時 2023-10-17 08:05:28
合計ジャッジ時間 2,071 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 656 ms
11,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

double dp[1000100];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int T;cin>>T;
  repeat(t,T){
    int N;cin>>N;
    repeat(i,N+10){
      dp[i]=0;
    }
    for(int i=N-1;i>=0;i--){
      dp[i] = dp[i+1]/12+dp[i+2]/6+dp[i+3]/4+dp[i+4]/12+dp[i+5]/4+dp[i+6]/6+1;
    }
    printf("%.6lf\n",dp[0]);
  }
  return 0;
}
0