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

WA???

Posted by cycpp at 2008-12-09 17:22:59 on Problem 2249
#include <iostream>
using namespace std;
bool b[1000];
int main()
{
	int i,j,m,n,mul;
	while(cin>>m>>n&&m)
	{
		if(n>m/2)n=m-n;
		if(n==0)cout<<1<<endl;
		else
		{
			mul=1;
			memset(b,false,sizeof(b));
			for(i=m;i>=m-n+1;i--)
			{
				mul*=i;
				for(j=2;j<=n;j++)
				{
					if(!b[j]&&mul%j==0)
					{
					   mul/=j;
					   b[j]=true;
					}
				}
			}
			cout<<mul<<endl;
		}
	}
	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