View Code of Problem 102

#include<iostream>

using namespace std;

long long gcd(long long a, long long b){
	if(b==0)
		return a;
	else
		return gcd(b, a%b);
}

int main(){
	
	long long x0, y0;
	while(cin>>x0>>y0){
		if(x0==y0)
			cout<<1<<endl;
		else{
			int count=0;
			long long a=x0, b=y0;
			long long mul=x0*y0;
			
			while(a<=y0&&a<b){
				if(gcd(a, b)==x0&&a*b==mul){
					count++;
				}
				a+=x0;
				b=mul/a;
			}
			cout<<count*2<<endl;
		}
	}
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 102