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

Re:我的程序,希望对大家有提示

Posted by neu_swc at 2009-07-29 22:05: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;
> }
> 这里是不是有问题啊,我觉得j可能会变成负数的

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