View Code of Problem 102

#include<bits/stdc++.h>

using namespace std;

long long  gcd(long long  a,long long  b)
{
    if(b == 0)
        return a;
    else
        return gcd(b,a % b);
}

int main()
{
    long long x , y, p;
    while(cin >> x >>y){
    int sum =0;
    if(y % x != 0) cout << 0 <<endl;
    else if(x == y) cout<< 1 <<endl;
    else{
    for(int i = x; i <= x * y; i++){
         p = x * y;
        if(x == gcd(i,p / i) && i < p / i)
           sum += 2;
    }
    cout << sum <<endl;
    }
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 102