0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 00:18:48 +00:00

[NOI Online 2022 普及组] 数学游戏(民间数据)

R72648237
This commit is contained in:
Baoshuo Ren 2022-03-28 21:53:09 +08:00
parent ed7e55aea1
commit e4a539a85b
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

36
Luogu/P8255/P8255.cpp Normal file
View File

@ -0,0 +1,36 @@
#include <algorithm>
#include <cmath>
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
int t;
long long x, z;
int main() {
std::ios::sync_with_stdio(false);
cin >> t;
while (t--) {
cin >> x >> z;
if (!z) {
cout << 0 << endl;
continue;
}
long long yg = z / x,
gg = std::__gcd(x * x, yg),
g = std::sqrt(gg);
if (gg != g * g || z % x) {
cout << -1 << endl;
} else {
cout << yg / g << endl;
}
}
return 0;
}