View Code of Problem 102

#include <stdio.h>
#include <string.h>
#include <math.h>
int gys(int a,int b){
	int t;
	if(a>b){
		t=a;
		a=b;
		b=t;
	}
	while(b!=0){
		t=a%b;
		a=b;
		b=t;
		
	}
	return a;
}

int main(){
	long int x,y;
	long int i;
	while(scanf("%ld %ld",&x,&y)!=EOF){
		long int count=0;
		if(x==y)
			printf("1\n");
		else{
			for(i=x;i<=sqrt(y*x);i++){
			if(y%i==0&&gys(x*y/i,i)==x)
			count++;
		}
	
		printf("%ld\n",count*2);
			
			
		}	
		
		
	}
}

Double click to view unformatted code.


Back to problem 102