View Code of Problem 102

#include<stdio.h>
#include<math.h>
long long int gcd(const long long int a,const long long int b){
	return b?gcd(b,a%b):a;
}
long long  int lcm(const long long int a,const long long int b){
	return a/gcd(a,b)*b;
}
int main(){
	long long int x0,y0,i,j;
	while(scanf("%lld %lld",&x0,&y0)!=EOF){
	long long int c=0;
	if(x0==y0)
	{
		printf("1\n");
	}
	else{
		for(i=x0;i<=sqrt(x0*y0);i++){
			for(j=y0;j>=sqrt(x0*y0);j--)
			if(gcd(i,j)==x0&&lcm(i,j)==y0)
			c++;
		}
		printf("%lld\n",2*c);
	}
}
}

Double click to view unformatted code.


Back to problem 102