D - Find Integer
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
a^n+b^n=c^n,给出a和n,求满足条件的b和c,没有输出“-1 -1“
费马大定理
当整数n >2时,关于x, y, z的方程 x^n + y^n = z^n 没有正整数解
整数边三角形
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<fstream>
#include<math.h>
#include<stack>
#include<queue>
#include<bitset>
#include<utility>
#include<set>
#include<map>
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const double eps=0.0000000000001;
const ll mod=1000000007;
int t;
int n;
int main(){
scanf("%d",&t);
while(t--){
int a,n;
scanf("%d%d",&n,&a);
if(n==1){
printf("%d %d\n",a+1,a+a+1);
}
else if(n==2){
int b,c;
if(a%2==1){
b=(a*a-1)/2;
c=(a*a+1)/2;//c=b+1
}
else{
b=a*a/4-1;
c=a*a/4+1;//c=b+2
}
printf("%d %d\n",b,c);
}
else printf("-1 -1\n");
}
return 0;
}
整数边直角三角形相关性质
(来自https://wenku.baidu.com/view/98be9b19ff00bed5b9f31d6c.html)
1、
a 和b 都是正整数, 且a > b。( x, y, z )称为勾股弦数组, x, y 为勾股数, 表示直角边长, z为弦数, 表示斜边之长
2、以任何大于2的正整数为直角边的整数边直角三角形一定存在
3、以任何大于2的素数q 为直角边的整数边直角三角形有且仅有一个, 且为
以任何大于2的正整数n 为直角边的整数边直角三角形的个数大于等于1, 小于等于n的二分之一
ex:
n 为偶数时,若y 为偶数, 则z 必为偶数; 若y 为奇数, 则z必为奇数, 即y, z 同奇偶。所以, 我们可设:z = y+ 2k ( k 为正整数)于是, 以n 为直角边的任一整数边直角三角形具有形式( n, y, y+ 2k )
同理可求得n为奇数时, 以n 为直角边的整数边直角三角形
4、