rt,https://www.luogu.com.cn/record/74268769
#include <bits/stdc++.h>
using namespace std;
#define int long long
int t;
int gcd(int a, int b) {
if (a % b == 0) return b;
return gcd(b, a % b);
}
signed main() {
cin >> t;
while (t--) {
int x, y, z;
cin >> x >> z;
int a = z / x, b = x * x, c = sqrt(gcd(a, b));
y = a / c;
if (c * c != gcd(a, b)) cout << -1 << endl;
else cout << y << endl;
}
return 0;
}
TLE 的问题应该不用担心,写个快读就行了,毕竟复杂度是正解复杂度。
还有就是我不理解为啥这个代码官方 75 pts,洛谷 0 pts 啊(