| ||||||||||
| 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 <iostream>
#include <iomanip>
using namespace std;
int main(){
long i,j,k,c,n,m;
double a[120][2050];
while (1==1){
cin >> c ;
if (c==0) {break;};
cin >> n >> m;
cout.setf(ios_base::fixed, ios_base::floatfield);
cout.precision(3);
if (m>c+1){cout<<0.0<<endl;}
else{
if (n>2000){
if (n % 2 == 0) {n = 2000;}
else {n = 2001;};};
for (i=0;i<=n;i++){
a[c+1][i]=0;
}
for (j=0;j<=c;j++){
a[j][1]=0;
}
a[1][1]=1;
for (j=2;j<=n;j++){
for (i=0;i<=c;i++){
if (i==0) {
a[i][j]=a[i+1][j-1]*(i+1.0)/c;
}
else{
a[i][j]=a[i-1][j-1]*(1-(i-1.0)/c)+a[i+1][j-1]*(i+1.0)/c;
}
}
}
cout<<a[m][n]<<endl;
}
}
return 0;
}
幫忙謝謝!
有數據嗎?
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator