给出n和a求b, c满足a^n + b^n = c^n
由费马大定理得出n > 2时无解,n = 2时参考勾股数
#include <cstdio>
typedef long long ll;
int main() {
int T;
scanf("%d", &T);
while (T--) {
ll n, a, b, c;
scanf("%lld%lld", &n, &a);
if (n == 1) {
printf("%lld %lld\n", 1, 1+a);
}
else if (n == 2) {
if (a % 2 == 1) {
ll tmp = (a-1)/2;
b = 2*tmp*tmp+2*tmp;
c = b+1;
printf("%lld %lld\n", b, c);
}
else {
ll tmp = a/2 - 1;
b = tmp*tmp + 2*tmp;
c = b + 2;
printf("%lld %lld\n", b, c);
}
}
else printf("-1 -1 \n");
}
return 0;
}