• 板块灌水区
  • 楼主zcy_jake
  • 当前回复6
  • 已保存回复6
  • 发布时间2024/10/5 19:06
  • 上次更新2024/10/5 20:12:43
查看原帖
1041218
zcy_jake楼主2024/10/5 19:06

P8255
代码 :

#include<bits/stdc++.h>
#define int long long
using namespace std;
int t,x,z;
signed main() {
//	freopen("math.in","r",stdin);
//	freopen("math.out","w",stdout);
	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记录

2024/10/5 19:06
加载中...