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

这样s竟然不会溢出 -_-!!

Posted by HG at 2009-04-21 20:39:40 on Problem 2249
In Reply To:我的程序,希望对大家有提示 Posted by:382784268 at 2009-03-06 21:51:51
> #include<iostream>
> using namespace std;
> int main()
> {
> 	int n,k;
> 	while(cin>>n>>k)
> 	{
> 		if(n==0&&k==0)
> 			break;
> 		int i=0;
> 		if(k>n/2)
> 			k=n-k;
> 		int j=k;
> 		__int64 sum=1;
> 		__int64 s=1;
> 		while(i<k)
> 		{
> 			sum*=n;
> 			n--;
> 			i++;
> 			if(sum%j==0)
> 				sum=sum/j;
> 			else
> 				s*=j;
> 			j--;
> 		}
> 		sum/=s;
> 	    printf("%I64d\n",sum); 
> 	}
> 	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