Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

高手指點, 老是WA

Posted by stanfordyeung at 2010-10-02 18:34:54 on Problem 1322
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator