View Code of Problem 102

#include<iostream>
#include<string>
using namespace std;
long gcd(long a, long b) {
	if (b == 0)
		return a;
	return gcd(b, a%b);
}
int main() {
	long x, y;
	while (cin >> x >> y) {
		int sum = 0;
		for (long i = x; i <= y; i+=x)
			for (long j = x; j <= y; j+=x)
				if (gcd(i,j) == x && i*j/x == y)
					sum++;
		cout << sum << endl;
	}
}

Double click to view unformatted code.


Back to problem 102