蒟蒻求助玄关
  • 板块灌水区
  • 楼主封禁用户
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/8/5 09:57
  • 上次更新2024/8/5 10:48:34
查看原帖
蒟蒻求助玄关
1401572
封禁用户楼主2024/8/5 09:57

P1072

TLE一个

我的code

#include<bits/stdc++.h>

//#define ?
#define endl "\n"
#define Fc ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define maxn 1005

using namespace std;

ll lcm(ll x, ll y) {
	return x * y / __gcd(x, y);
}
ll t, a0, a1, b0, b1;

int main() {

	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);


	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	scanf("%lld", &t);
	while (t--) {
		ll cnt = 0;
		scanf("%lld%lld%lld%lld", &a0, &a1, &b0, &b1);
		for (ll x = 1; x <= b1 / x; ++x) {
			if (b1 % x == 0) {
				if (__gcd(x, a0) == a1 && lcm(x, b0) == b1)
					++cnt;
				if (b1 / x != x)
					if (__gcd(b1 / x, a0) == a1 && lcm(b1 / x, b0) == b1)
						++cnt;
			}
		}
		printf("%lld\n", cnt);
	}

	return 0;
}
2024/8/5 09:57
加载中...