#include"bits/stdc++.h" using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } using Real=long double; /* dp[x] := 和xから和N以上にする期待値 dp[x] = 1 + p[1]*dp[x+1] + p[2]*dp[x+2] + p[3]*dp[x+3] + p[4]*dp[x+4] + p[5]*dp[x+5] + p[6]*dp[x+6] if x >=N then dp[x] = 0 これを逆転する考察が良い dp[x] := xからサイコロで引いていって,0以下にする期待値 dp[x] = 1 + p[1]*dp[x-1] + p[2]*dp[x-2] + p[3]*dp[x-3] + p[4]*dp[x-4] + p[5]*dp[x-5] + p[6]*dp[x-6] if x <= 0 then dp[x] = 0 dp[2] = 1.0833333333333333 = 1 + p[1] * dp[1] p[1] = 1.0833333333333333 - 1.0 = 0.0833333333333333 dp[3] = 1.2569444444444444 = 1 + p[1] * dp[2] + p[2] * dp[1] p[2] = 0.2569444444444444 - p[1] * dp[2] dp[4] = 1.5353009259259260 = 1 + p[1] * dp[3] + p[2] * dp[2] + p[3] * dp[1] p[3] = dp[4] - 1 - p[1]*dp[3] - p[2]*dp[2] */ signed main(){ vector p(7); vector dp(1010000); dp[0]=0; dp[1]=1.0000000000000000; dp[2]=1.0833333333333333; dp[3]=1.2569444444444444; dp[4]=1.5353009259259260; dp[5]=1.6915991512345676; dp[6]=2.0513639724794235; p[0]=0; p[1]=0.0833333333333333; p[2]=dp[3]-1-p[1]*dp[2]; p[3]=dp[4]-1-p[1]*dp[3]-p[2]*dp[2]; p[4]=dp[5]-1-p[1]*dp[4]-p[2]*dp[3]-p[3]*dp[2]; p[5]=dp[6]-1-p[1]*dp[5]-p[2]*dp[4]-p[3]*dp[3]-p[4]*dp[2]; p[6]=1-p[1]-p[2]-p[3]-p[4]-p[5]; for(int i=7;i<=1000100;i++){ dp[i]=1; for(int j=1;j<=6;j++) dp[i]+=dp[i-j]*p[j]; } int q;cin>>q; while(q--){ int X;cin>>X; cout<