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

到底错那了??

Posted by bushiniao at 2006-11-10 17:12:03 on Problem 2649
#include<iostream.h>
#include <math.h>

int gcd(int a,int b)
{
	return a == 0 ? b : gcd(b % a, a); 
}

bool res(int m,int n)
{
	if(m==1)
		return true;
	if(n==1&&m!=1)
		return false;
	int temp=gcd(m,n);
	return res(m/temp,n-1);	
}
int main()
{
	int m,n;
	while(cin>>m>>n)
	{
		if(n==0)
			cout<<n<<" does not divide "<<m<<"!"<<endl;
		else
		if(m==0||m==1)
		{
			if(n==1)
				cout<<"1 divides "<<m<<"!"<<endl;
			else
				cout<<n<<" does not divide "<<m<<"!"<<endl;
		}
		else
		{
			if(res(n,m))
				cout<<n<<" divides "<<m<<"!"<<endl;
			else
				cout<<n<<" does not divide "<<m<<"!"<<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