P8255
代码 :
#include<bits/stdc++.h>
#define int long long
using namespace std;
int t,x,z;
signed main() {
cin >> t;
for(int i = 1 ; i <= t ; i ++) {
cin >> x >> z;
if(z % x != 0) cout << "-1" << endl;
else {
int d1 = z / x,d2 = x * x;
int v = __gcd(d1,d2);
int k = (int)sqrt(v);
if(k * k != v) cout << "-1" << endl;
else cout << d1 / k << endl;
}
}
return 0;
}
这道题目我把第十三行的 x * x 改成 pow(x,2) 就过不了,请问这是为什么?
AC记录
WA记录