#include using namespace std; typedef long long LL; #ifdef BTK #include #define DEBUG if(1) #else #define CIN_ONLY if(1) struct cww{cww(){ CIN_ONLY{ ios::sync_with_stdio(false);cin.tie(0); } }}star; #define DEBUG if(0) #endif #define fin "\n" #define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() #define fi first #define se second #define pb push_back #define REC(ret, ...) std::function template inline bool chmin(T &l,T r) {bool a=l>r;if(a)l=r;return a;} template inline bool chmax(T &l,T r) {bool a=l istream& operator>>(istream &is,vector &v){ for(auto &it:v)is>>it; return is; } int n,m; typedef double D; constexpr D eps = 1e-10; inline bool isZero(D x){ return abs(x) Vec; void calc(vector& mat){ REP(i,n){ int p = i; FOR(j,i,n){ if(!isZero(mat[j][i])){ p=j; break; } } swap(mat[i],mat[p]); REP(j,n+1)if(i!=j)mat[i][j]/=mat[i][i]; mat[i][i] = 1; REP(j,n)if(i!=j){ REP(k,n+1)if(i!=k)mat[j][k]-=mat[i][k]*mat[j][i]; mat[j][i]=0; } } } void solve(int v,Vec& dp,vector &vis,Vec& in,vector&mat){ if(vis[v]==1)return; vis[v]=1; dp[v]=0; if(n-1-v<=m){ return; } FOR(i,1,m+1){ solve(v+i,dp,vis,in,mat); dp[v]+=(in[v+i]+dp[v+i])/m; } FOR(i,1,m+1){ chmin(dp[v],in[v+i]+mat[v+i].back()); } } int main(){ cin>>n>>m; cout< x; vector in(n,0.0); Vec dp(n,0.0); vector vis(n,0); FOR(i,1,n-1)cin>>in[i]; REP(i,n-1){ Vec y(n+1); FOR(j,1,m+1){ int nxt= i+j+1; if(nxt>n)nxt=2*n-nxt; nxt--; y[nxt]+=1.0/m; y.back()-=in[nxt]/m; } y[i]-=1.0; x.pb(y); } x.pb(Vec(n+1,0.0)); x.back()[n-1]=1.0; calc(x); solve(0,dp,vis,in,x); cout<