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 emperorlu at 2008-01-15 13:54:59 on Problem 2249
TLE:
#include<stdio.h>
int main()
{
    int n,m;
    while(1)
    {
        scanf("%d%d",&n,&m);
        if(!n)break;
        double result=1;
        if(n<2*m)m=n-m;
        for(int i=1;i<=m;i++)
            result=result*(n+1-i)/i;
        printf("%.0lf\n",result);
    }
    return 0;
}

AC:0ms
#include<stdio.h>
int main()
{
    unsigned n,m;
    while(1)
    {
        scanf("%d%d",&n,&m);
        if(!n)break;
        double result=1;
        if(n<2*m)m=n-m;
        for(int i=1;i<=m;i++)
            result=result*(n+1-i)/i;
        printf("%.0lf\n",result);
    }
    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