View Code of Problem 102

#include<stdio.h>
#include<math.h>
int GCD(int a, int b){
	if(b==0) return a;
	else return GCD(b, a % b); 
}

int main(){
	long long x, y;
	while(scanf("%lld %lld", &x, &y) != EOF) {
		if(x == y){
		   printf("1\n");	
		}
		else{
			long long product = x * y; //x与y的乘积就是p * q; 
			long long bound = sqrt(product);
			int cnt = 0;
			for(long long i=x; i<=bound; i++){ //y是最小公倍数 
				if(product % i == 0 && GCD(i, product/i) == x){
						cnt++;
					}
			}
			printf("%d\n", 2*cnt);
			
		}//else
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 102