View Code of Problem 102

#include<bits/stdc++.h>
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 x,y,i,count;
	while(cin>>x>>y){
		count=0;
		if(x==y){
			cout<<1<<endl;
		}
		else{
			for(i=x;i<=sqrt(x*y);i++){
			if(y%i==0&&gcd(x*y/i,i)==x){
				count++;
			}
		}
		cout<<count*2<<endl;
		}
		
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 102