View Code of Problem 102

#include<bits/stdc++.h>
using namespace std;

int main() {

	long long x,y;
	while(cin>>x>>y){
		int num=0;
		for(int i=x;i*i<=x*y;i++){
			if(i%x==0&&y%i==0){
				long long a=i;
				long long b=x*y/i;
				long long max=1;
				if(a<=b){
					for(int j=2;j<=a;j++){
						if(a%j==0&&b%j==0){
							max=j;
						}
					}
				} 
				if(max==x){
					if(a==b){
						num++;
					}else{
						num+=2;
					}
				}
			}
		}
		cout<<num<<endl;
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 102