View Code of Problem 102

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

int main() {

	int 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){
				int a=i;
				int b=x*y/i;
				int max=1;
				if(a<=b){
					for(int j=2;j<=a;j++){
						if(a%j==0&&b%j==0){
							max=j;
						}
					}
				} 
				if(max==x){
					num+=2;
				}
			}
		}
		cout<<num<<endl;
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 102