求助,全wa
查看原帖
求助,全wa
357139
_XiaoKY_楼主2022/4/10 17:43
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL gcd(LL a, LL b) {
	if (b == 0) return a;
	return gcd(b, a % b); 
}
int main() {
	LL x, y, T, s;
	cin >> T;
	double c;
	while(T--) {
		cin >> x >> y;
		if (y % x != 0) {
			cout << -1;
			continue;
		}
		c = sqrt(gcd(x * x, y / x) * 1.0);
		s = c;
		if (s != c) {
			cout << -1;
			continue;
		} 
	}
	cout << y / x / s << endl;
	return 0;
}
2022/4/10 17:43
加载中...