题干:

people in USSS love math very much, and there is a famous math problem . 

give you two integers nn,aa,you are required to find 22 integers bb,cc such that anan+bn=cnbn=cn.

Input

one line contains one integer TT;(1≤T≤1000000)(1≤T≤1000000) 

next TT lines contains two integers nn,aa;(0≤n≤1000(0≤n≤1000,000000,000,3≤a≤40000)000,3≤a≤40000) 

Output

print two integers bb,cc if bb,cc exits;(1≤b,c≤1000(1≤b,c≤1000,000000,000)000); 

else print two integers -1 -1 instead.

Sample Input


1 2 3

Sample Output


4 5

解题报告:

        根据费马大定理的结论,用奇偶构造法求出勾股定理中另外两个数。

AC代码:

#include<bits/stdc++.h>

using namespace std;

int main()
{
int t;
cin>>t;
while(t--) {
int n,a;
scanf("%d%d",&n,&a);
if(n > 2 || n==0) {
puts("-1 -1");
}
else if(n == 1) {
printf("1 %d\n",a+1);
}
else {
if(a&1) {
int tmp = (a-1)/2;
printf("%d %d\n",2*tmp*tmp + 2*tmp,2*tmp*tmp+2*tmp+1);
}
else {
int tmp = a/2 - 1;
printf("%d %d\n",tmp*tmp + 2*tmp,tmp*tmp + 2*tmp + 2);
}
}
}

return 0 ;
}

 

知识点:(勾股定理的构造)

【HDU - 6441】Find Integer (费马大定理 + 奇偶数列法构造勾股定理)_#include