Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
WA得不行了,高手指点#include <stdio.h> #include <string.h> double arr[1002][101]; int main(){ int c,m,n,i,j; while (scanf("%d",&c)) { if (!c) break; scanf("%d%d",&n,&m); memset(arr,0,sizeof(arr)); if (m>c||m>n){ printf("0.000\n"); continue; } if (n>1000) { if (n%2) n = 1001; else n = 1000; } arr[1][1] = 1; for (i=2;i<=n;++i) { for (j=0;j<=c;++j) { if (!j) arr[i][j] = arr[i-1][1]/c; else if (j==c) arr[i][j] = arr[i-1][c-1]/c; else arr[i][j] = arr[i-1][j-1]*(c-j+1)/c + arr[i-1][j+1]*(j+1)/c; } } printf("%.3lf\n",arr[n][m]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator