View Code of Problem 102

#include<bits/stdc++.h>
using namespace std;
int gcd(long int a,long int b){
	return a%b?gcd(b,a%b):b;
}
int main(){
	long int x,y,p;
	while(cin>>x>>y){
		if(x==y){
			printf("1\n");	
		}else{
			int cnt=0;
			for(p=x;p<=sqrt(x*y);p++){
				if(((x*y)%p)==0&&gcd(p,x*y/p)==x){
					cnt++;
				}
			}
			printf("%d\n",cnt*2);
		}
	} 
}

Double click to view unformatted code.


Back to problem 102