View Code of Problem 102

#include<iostream>

using namespace std;

int 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){
		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