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 gaoxingok99 at 2009-07-23 16:09:04 on Problem 2249
我的代码如下;测试数据是对的,可提交就是不对!
#include<stdio.h>
int main()
{
	int n,k,i;
	scanf("%d%d",&n,&k);
	while(1)
	{
		long int result=1;
		if(n==0&&k==0) break;
	    else if((n==k)||(k==0))
			printf("1\n");
		else
		{ 
			if(k>n/2) k=n-k;
		    
		    for(i=1;i<=k;i++)
			{
			   result=result*n;
			   n--;
			   result=result/i;
			}
		    printf("%d\n",result);
		}
	    scanf("%d%d",&n,&k);
	}
	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