题目链接http://acm.hdu.edu.cn/showproblem.php?pid=6441
费马定理,大于2是无解的
n=2时
当a是偶数时,b与c相差2;
当a是奇数时,b与c相差1;
在判断n=1时的情况
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#define ll long long
#define PI 3.1415926535897932384626
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=2e6+10;
long long b,c,n;
int a;
int main()
{
int t;
scanf("%d",&t);
while(t--){
scanf("%lld%d",&n,&a);
if(n==0||n>2){
b=-1;c=-1;
}
if(n==1){
b=1;c=a+1;
}
if(n==2){
if(a%2==0){
b=(a*a-4)/4;
c=b+2;
}
else{
b=(a*a-1)/2;
c=b+1;
}
}
printf("%lld %lld\n",b,c);
}
}