原题链接
solution:主要是数学东西太复杂了
不知道费马大定理和奇偶数列法则的可以看看我的博客
这个题还一个需要注意的地方就是用cin和cout会超时,最后全部改成scanf和printf才过的
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, a, t;
scanf("%d", &t);
while (t--){
scanf("%d %d", &n, &a);
if (n == 1)printf("1 %d\n", a + 1);
else if (n != 2)printf("-1 -1\n");
else{
if (a % 2){
int temp = (a - 1) / 2;
int c = temp * temp + (temp + 1) * (temp + 1);
int b = c - 1;
printf("%d %d\n", b, c);
}else{
int temp = a / 2;
int b = temp * temp - 1;
int c = b + 2;
printf("%d %d\n", b, c);
}
}
}
return 0;
}



京公网安备 11010502036488号