View Code of Problem 102

#include<bits/stdc++.h>
using namespace std;
int gcd(int,int);
int main(){
	int x,y;
	while(scanf("%d%d",&x,&y)!=EOF){
		int num = 0;
		int sqr = (int)sqrt(x*y); 
		for(int i = 1;i<=sqr;i++){
			if((x*y) % i ==0){
				if(gcd(i,(x*y)/i)==x)num+=2;
			}
		}
		cout<<num<<endl;
	}
	
	return 0;
} 
int gcd(int a,int b){
	int t;
	while(b!=0){
		t = a%b;
		a = b;
		b = t;
	}
	return a;
//	if(b==0)return a;
//	else return gcd(b,a%b);
} 

Double click to view unformatted code.


Back to problem 102