#include
#include
#include
int n;
long long anstot;
long long a0, a1, b0, b1;
long long gcd(long long x, long long y) {
if (y == 0) return (x);
return (gcd(y, x % y));
}
int main () {
freopen("son.in", "r", stdin);
freopen("son.out", "w", stdout);
scanf("%d", &n);
while (n--) {
anstot = 0;
scanf("%lld %lld %lld %lld", &a0, &a1, &b0, &b1);
for (long long x = a1; x <= b1; x++) {
if (gcd(x, a0) != a1) continue;
long long tx = gcd(x, b0);
if (x * b0 / tx != b1) continue;
anstot++;
}
printf("%lld\n", anstot);
}
return 0;
}
#include
#include
#include
#include
int n;
long long anstot;
long long a0, a1, b0, b1;
long long gcd(long long x, long long y) {
if (y == 0) return (x);
return (gcd(y, x % y));
}
void check(long long x) {
if (gcd(x, a0) != a1) return;
long long cur = gcd(x, b0);
if (x * b0 / cur != b1) return;
anstot++;
}
int main () {
freopen("son.in", "r", stdin);
freopen("son.out", "w", stdout);
scanf("%d", &n);
while (n--) {
anstot = 0;
scanf("%lld %lld %lld %lld", &a0, &a1, &b0, &b1);
long long c = sqrt(b1);
for (long long x = 1; x <= c; x++) {
if (b1 % x != 0) continue;
check(x);
if (x * x == b1) continue;
check(b1 / x);
}
printf("%lld\n", anstot);
}
return 0;
}
90分了,,,再想想,把long long改成int,check的时候压一下常数。。
#include
#include
#include
#include
int n;
long long anstot;
int a0, a1, b0, b1;
int gcd(int x, int y) {
if (y == 0) return (x);
return (gcd(y, x % y));
}
void check(int x) {
if (x % a1) return;
if (gcd(x/a1, a0/a1) == 1 && gcd(b1/b0, b1/x) == 1) anstot++;
}
int main () {
freopen("son.in", "r", stdin);
freopen("son.out", "w", stdout);
scanf("%d", &n);
while (n--) {
anstot = 0;
scanf("%d %d %d %d", &a0, &a1, &b0, &b1);
long long c = sqrt(b1);
for (int x = 1; x <= c; x++) {
if (b1 % x != 0) continue;
check(x);
if (x * x == b1) continue;
check(b1 / x);
}
printf("%lld\n", anstot);
}
return 0;
}
好像A了,,,,=。=