1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > ACM—数论—费马大定理 (数学史上著名的定理)

ACM—数论—费马大定理 (数学史上著名的定理)

时间:2022-04-26 03:16:29

相关推荐

ACM—数论—费马大定理 (数学史上著名的定理)

百度词条

费马大定理,又被称为“费马最后的定理”,由17世纪法国数学家皮耶·德·费玛提出。

它断言当整数n >2时,关于x, y, z的方程 x^n + y^n = z^n 没有正整数解。

德国佛尔夫斯克曾宣布以10万马克作为奖金奖给在他逝世后一百年内,第一个证明该定理的人,吸引了不少人尝试并递交他们的“证明”。

被提出后,经历多人猜想辩证,历经三百多年的历史,最终在1995年被英国数学家安德鲁·怀尔斯彻底证明。

CCPC 网赛的一题

1004 Find Integer

Problem

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

give you two integers , ,you are required to find integers , such that

.

Input

one line contains one integer T ;

next lines contains two integers n,a;

Output

print two integers , if , exits b,c print one of the answers

else print two integers -1 -1 instead.

Sample Input

1

2 3

Sample Output

4 5

对于,给出a,n,求是否存在b,c满足题意。

n>2时由费马大定理知无解,n=0时易知无解,n=1无脑输出答案即可。

只有n==2的情况,根据奇偶数列法则可得。

代码如下:

#include <iostream>#include <cstdio>#include <cstring>using namespace std;#define ll long longll T, a, b, c, n;int main(){cin>>T;while(T--){cin>>n>>a;if(n == 2){if(a%2){ll t = (a-1)/2;c = t*t+(t+1)*(t+1);b = c-1;}else{ll t = (a+2)/2;c = 1+(t-1)*(t-1);b = c-2;}cout<<b<<' '<<c<<endl;}else if( n == 1){cout<<1<<' '<<a+1<<endl;}else{cout<<-1<<' '<<-1<<endl;}}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。