求助65分,部分点输出负号但已经开到ull了
查看原帖
求助65分,部分点输出负号但已经开到ull了
477258
charleshe楼主2022/8/3 18:59
#include <iostream>
#include <cmath>
#include <algorithm>
#define int unsigned long long
using namespace std;
int t,x,z;
signed main(){
	cin>>t;
	while(t--){
		cin>>x>>z;
		if(z%x) cout<<"-1\n";
		long double tmp1=__gcd(z/x,x*x);
        int tmp=tmp1;
		int t=sqrt(tmp)+0.5;
		if(t*t!=tmp) cout<<"-1\n";
		else cout<<(z/x)/t<<endl;
	}
	return 0;
}
2022/8/3 18:59
加载中...