zju 1003 Crashing Balloon( 鸡吧题)

不会,!!

#include <iostream>
#include <cstring>
using namespace std;
#define MAX_N 101
bool succeedn,succeedm;
int n,m;
void Divide(int n,int m,int k){

	if(m==1){
		if(n==1)
			succeedn=true;
		succeedm=true;
	}
	if( k<2 || (succeedm && succeedn))
		return ;
	if(!(n % k))
		Divide(n/k,m,k-1);
	if(!(m % k))
		Divide(n,m/k,k-1);
		Divide(n,m,k-1);
}
int main(){

	while(cin>>n>>m){
		if(m>n)
		swap(n,m);
		succeedn=succeedm=false;
		Divide(n,m,100);
		if(succeedn)
			cout<<n<<endl;
		else if(succeedm)
			cout<<m<<endl;
	}
	return 0;
}


 

你可能感兴趣的:(zju 1003 Crashing Balloon( 鸡吧题))