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

谁能告诉我错哪了。。。

Posted by highkobe at 2008-10-16 23:59:48 on Problem 1322
#include<stdio.h>
#include<string.h>
#define N 105
double a[1005][N];
int main()
{
    int i,j,n,m,s,p;
    double c,add,num;
    while(scanf("%lf",&c),c)
    {
        scanf("%d%d",&n,&m);
        if(m>c||m>n)
        {
            printf("0.000\n");
            continue;
        }
        if(n>1000)
        {
            if(n%2==1)
            n=1001;
            else
            n=1000;
        }
        for(i=0;i<=n;i++)
        for(j=0;j<=(int)c;j++)
        a[i][j]=0;
        a[1][1]=1;
        add=1/c;
        for(i=1;i<n;i++)
        {
            for(j=0;j<=(int)c;j++)
            {
               // printf("%d----i\n%d-----j\n",i,j);
                if(j==0)
                {
                    a[i+1][1]+=a[i][j];
                }
                else
                {
                    a[i+1][j+1]+=a[i][j]*add*(c-(double)j);
                    num=a[i][j]*add*j;
                    a[i+1][j-1]+=num;
                }
            }
        }
        printf("%.3lf\n",a[n][m]);
    }
    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