日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Find Integer(费马大定理的使用)

發(fā)布時(shí)間:2024/10/14 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Find Integer(费马大定理的使用) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Problem Description

people in USSS love math very much, and there is a famous math problem .

give you two integers n ,a ,you are required to find 2 integers b ,c such that an +bn=cn .

?

?

Input

one line contains one integer T ;(1≤T≤1000000)

next T lines contains two integers n ,a ;(0≤n≤1000 ,000 ,000,3≤a≤40000)

?

?

Output

print two integers b ,c if b ,c exits;(1≤b,c≤1000 ,000 ,000) ;

else print two integers -1 -1 instead.

?

?

Sample Input

?

1 2 3

?

?

Sample Output

?

4 5

?

?

費(fèi)馬大定理在加上勾股數(shù)的一些規(guī)律:

費(fèi)馬大定理:

a^n+b^n=c^n在n>2時(shí)是不成立的。

勾股數(shù)規(guī)律:

https://wenku.baidu.com/view/8282f1b669eae009591bec85.html

?

?

#include <iostream>
using namespace std;

int main() ? ? ?
{
?? ?int T;
?? ?scanf("%d",&T);
?? ?int n,a,b,c;
?? ?while(T--)
?? ?{
?? ??? ?scanf("%d %d",&n,&a);
?? ??? ?if(n>2||n==0)
?? ??? ?{
?? ??? ??? ?printf("-1 -1\n");
?? ??? ??? ?continue;
?? ??? ?}
?? ??? ?else if(n==1)
?? ??? ?{
?? ??? ??? ?printf("%d %d\n",1,a+1);
?? ??? ??? ?continue;
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?if(a%2==0) ? ? ? ? ?//a為偶數(shù)的時(shí)候
?? ??? ??? ?{
?? ??? ??? ??? ?int temp=(a-2)/2;
?? ??? ??? ??? ?printf("%d %d\n",temp*temp+2*temp,temp*temp+2*temp+2);?
?? ??? ??? ??? ?continue;
?? ??? ??? ?}?
?? ??? ??? ?else
?? ??? ??? ?{
?? ??? ??? ??? ?int temp=(a-1)/2;
?? ??? ??? ??? ?printf("%d %d\n",2*temp*temp+2*temp,2*temp*temp+2*temp+1);
?? ??? ??? ??? ?continue;
?? ??? ??? ?}
?? ??? ?}
?? ?}?? ??? ??? ??? ?
?? ?return 0;?? ?
}?

?

總結(jié)

以上是生活随笔為你收集整理的Find Integer(费马大定理的使用)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。