ans

zhaocong 2022-04-03 12:31:45 6 返回题目

#include<bits/stdc++.h>

using namespace std;

long long t,x,z;

int main(){

scanf("%lld",&t);

while(t--){

	scanf("%lld%lld",&x,&z);

	if(z%x!=0){

		printf("-1\n");

		continue;

	}

	long long m=__gcd(z/x,x*x);

	long long q=sqrt(m);

	if(q*q!=m) 		printf("-1\n");

	else 			printf("%lld\n",(z/x)/q);

}

return 0;

}

{{ vote && vote.total.up }}