#include<stdio.h>
#include<string.h>
double dp[3][160];
int main()
{
int n,m,c;
while(~scanf("%d",&c)&&c)
{
scanf("%d%d",&n,&m);
if(n>1000)
{
if(n&1)
n=1001;
else
n=1000;
}
if(m>c||(n+m)&1)
printf("0.000\n");
else
{
memset(dp,0,sizeof(dp));
dp[0][0]=1;
int tot=0,s=0;
while(tot<n)
{
s^=1;
tot++;
dp[s][0]=dp[s^1][1]/c;
dp[s][c]=dp[s^1][c-1]/c;
for(int j=1;j<c;j++)
dp[s][j]=dp[s^1][j-1]*(c-j+1)/c+dp[s^1][j+1]*(j+1)/c;
}
printf("%.3f\n",dp[s][m]);
}
}
return 0;
}
poj 1322 概率dp
最新推荐文章于 2019-12-27 20:46:07 发布