Find Integer(大费马定理&&勾股定理)
发布日期:2022-04-22 13:49:15 浏览次数:7 分类:技术文章

本文共 473 字,大约阅读时间需要 1 分钟。

【】

当整数n >2时,关于x, y, z的方程 x^n + y^n = z^n 没有正整数解。故,只考虑n=1, n=2, n=0

当n=0时,肯定不成立;

当n=1时,该题是特判,所以输出一组就好了;

当n=2时,。

【代码】

#include
using namespace std;int main(){ int t; scanf("%d",&t); while(t--) { int n,a; scanf("%d%d",&n,&a); if(n>2||n==0)printf("-1 -1\n"); else if(n==1)//输出一组就好 printf("%d %d\n",1,1+a); else{ int k=a/2; if(a&1)//a为大于1的奇数 printf("%d %d\n",2*k*k+2*k,2*k*k+2*k+1); else //a为大于4的偶数2n printf("%d %d\n",k*k-1,k*k+1); } } return 0; }

 

转载地址:https://wslxya.blog.csdn.net/article/details/82078590 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:find 函数
下一篇:final和static关键字

发表评论

最新留言

不错!
[***.144.177.141]2024年04月19日 17时42分40秒