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 MasterLuo at 2008-11-29 17:39:10 on Problem 2249
In Reply To:程序改成这样还说错误的啊,wr Posted by:382784268 at 2008-11-29 16:32:12
#include <iostream>
using namespace std;
int main()
{
	int n, k;
	cin>>n>>k;
	while((n!=0) || (k!=0))
	{
		if((n==k) || (k==0))
		    cout<<1<<endl;
		else
		{
			if(k>n/2)
				k=n-k;
			long long int result=1;
			for(int i=1; i<=k; i++)
			{
				result=result*n;
				n--;
				result=result/i;
			}
			cout<<result<<endl;
		}
		cin>>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