题目大意
已知a,n求a^n+b^n=c^n,根据费马大定理可知,当n>2时无解 n==0易知无解。
n=1,b=1,c=a+b;
n=2,即为勾股数。
Ps
cin wa,可采用打表,或用scanf
AC code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int INF=0x3f3f3f3f;
int main() {
int t,n,a;
ll b,c,tem;
scanf("%d",&t);
while(t--) {
scanf("%d%d",&n,&a);
if(n<1||n>2) printf("-1 -1\n");
else if(n==1) printf("%d %lld\n",1,a+1);
else {
tem=a/2;
if(a%2==0) {
b=tem*tem;
printf("%lld %lld\n",b-1,b+1);
} else {
b=(tem)*(tem)*2+2*tem;
printf("%lld %lld\n",b,b+1);
}
}
}
return 0;
}