#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 1010
using namespace std;
int n,m,k;
int a[N];
struct Matrix
{
double map[N];
};
Matrix ori;
Matrix bas;
Matrix bask;
Matrix ans;
Matrix c;
// f[i][j]表示第i次拿出标号为j的球的期望
// f[i][j]=f[i-1][j]+1/m*f[i-1][j-1]-1/m*f[i-1][j];
Matrix mul(Matrix a,Matrix b)
{
for(int i=1;i<=n;i++)
{
c.map[i]=0;
for(int j=1;j<=n;j++)
{
c.map[i]+=a.map[j]*b.map[(i-j+n+1)%n==0?n:(i-j+n+1)%n];
}
}
return c;
}
Matrix quick_my(Matrix a,int y)
{
Matrix ret;
memset(ret.map,0,sizeof(ret.map));
ret.map[1]=1;
while(y)
{
if(y&1)
{
ret=mul(ret,a);
}
a=mul(a,a);
y>>=1;
}
return ret;
}
int main()
{
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
for(int i=1;i<=n;i++)ori.map[i]=(double)a[i];
bas.map[1]=(double)(m-1)/(double)m;
bas.map[2]=1.0/(double)m;
bask=quick_my(bas,k);
ans=mul(ori,bask);
for(int i=1;i<=n;i++)printf("%.3lf\n",ans.map[i]);
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/wzq_qwq/article/details/47319597