Files
python/TangDou/AcWing_TiGao/T5/YueShuGeShu/200_0.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

37 lines
811 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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 main() {
// 输入
int n;
cin >> n;
// 最大2000次噢
while (n--) {
/*
读入四个数字
x 和 a0 的最大公约数是 a1
x 和 b0 的最小公倍数是 b1
*/
int a0, a1, b0, b1;
cin >> a0 >> a1 >> b0 >> b1;
// 每次记数器清0
int cnt = 0;
// 枚举a1的所有倍数
for (int x = a1; x <= b1; x += a1)
if (gcd(x, a0) == a1 && lcm(x, b0) == b1) cnt++;
printf("%d\n", cnt);
}
return 0;
}