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

Why WA?代码在2246就过了,这里就wa!

Posted by dingdongsheng at 2008-11-07 10:43:52 on Problem 1306
#include<stdio.h>
__int64 gcd(__int64 a,__int64 b)
{
     if(a < b)
	 {
		 __int64 temp=a;
		 a=b;
		 b=temp;
	 }
     __int64 c=a%b;
     while(c!=0)
     {
         a=b;
         b=c;
         c=a%b;
     }
     return b;     
}
void  main()
{
	int m,n,i;
	__int64 sum1=1;
	__int64 sum2=1;
	while(scanf("%d%d",&m,&n),m||n)
	{
		sum1=1;
		sum2=1;
		if(n>m/2)
			n=m-n;
		for(i=1;i<=n;i++)
		{
			sum1=sum1*(m-i+1);
			sum2=sum2*i;
			__int64 d=gcd(sum1,sum2);
			sum1/=d;
			sum2/=d;
		}
		printf("%d things taken %d at a time is %I64d exactly.\n",m,n,sum1/sum2);
	}
	
}

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