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.
|
|
|
|
#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;
|
|
|
|
|
}
|