You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
583 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
//最大公约数
int gcd(int x, int y) {
return y ? gcd(y, x % y) : x;
}
//最小公倍数
int lcm(int x, int y) {
return y / gcd(x, y) * x; //注意顺序防止乘法爆int
}
int cnt;
int x, y;
int main() {
//y的范围1e6,双重循环妥妥的TLE
cin >> x >> y;
//双重循环,傻查法,最基本,最朴素
for (int i = x; i <= y; i++)
for (int j = x; j <= y; j++)
if (gcd(i, j) == x && lcm(i, j) == y) cnt++;
cout << cnt << endl;
return 0;
}