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
题解:此题考察费马大定理,当n>=3时,a的n次方+b的n次方=c的n次方,将没有整数解,所以这个题只需判断,n=1和n=2的情况就好了,我们接下来,还要提一下,当n=2时,你需要点开
https://wenku.baidu.com/view/8282f1b669eae009591bec85.html
这个神奇的链接看一下。

AC代码:

#include<stdio.h>
int main()
{long long T,n,a;scanf("%lld",&T);while(T--){scanf("%lld%lld",&n,&a);if(n>=3||n==0){printf("-1 -1\n");}else if(n==1){printf("%lld %lld\n",a+1,2*a+1);}else if(n==2){if(a%2!=0){printf("%lld %lld\n",a*(a/2)+a/2,a*(a/2)+a/2+1);}else{printf("%lld %lld\n",(a*(a/2))/2-1,(a*(a/2))/2+1);}}}return 0;
}

HDU 6441 Find Integer(费马大定理)相关推荐

  1. HDU 6441 Find Integer 【费马大定理】

    传送门:HDU 6441 Find Integer Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/O ...

  2. 【2018-CCPC青岛网赛】 HDU - 6441 Find Integer

    [2018-CCPC青岛网赛] HDU - 6441 Find Integer 源链接: HDU - 6441 文源 :Blog 题意 已知等式,a^n + b ^ n = c ^ n,题目中给出 a ...

  3. hdu.6441 Find Integer

    hdu.6441 Find Integer 思路:费马大定理+勾股定理. 费马大定理内容:an+bn=cn,(n>2)a^n+b^n=c^n,(n>2)an+bn=cn,(n>2)时 ...

  4. 【hdu】6441 Find Integer - 费马大定理

    Find Integer 题解: 根据费马大定理很容易知道当 n>2 时,等式 a^n+b^n=c^n 是无整数解的. 再假设当 n=0 时,a^0=1.题目中说到 (1≤b,c≤1000,00 ...

  5. HDU 6441 Find Integer(数论)

    Description 给出n,an,an,a,求一组b,cb,cb,c使得an+bn=cna^n+b^n=c^nan+bn=cn Input 第一行一整数TTT表示用例组数,每组用例输入两个整数n, ...

  6. HDU 6441 Find Integer

    题目传送门 代码: #include<bits/stdc++.h> using namespace std;int main(){int T;scanf("%d",&a ...

  7. HDUOJ 6441 Find Integer

    HDUOJ 6441 Find Integer 题目链接 Problem Description people in USSS love math very much, and there is a ...

  8. 【HDU - 6441】Find Integer (费马大定理 + 奇偶数列法构造勾股定理)

    题干: people in USSS love math very much, and there is a famous math problem . give you two integers n ...

  9. hdu 6441 (费马大定理+勾股数 数学)

    题意是给定 n 和 a,问是否存在正整数 b,c 满足:a^n + b^n == c^n.输出 b  c,若不存在满足条件的 b,c,输出 -1 -1. 当 n > 2 时,由费马大定理,不存在 ...

最新文章

  1. 前端开发--播放页面评论区业务逻辑初步
  2. IIS中 flv、swf 文件无法播放
  3. MySQL常用语句一、连接MySQL格式:mysql-h主机地址-u用户名-p用户密
  4. 取消chrome浏览器下input和textarea的默认样式
  5. 《天天数学》连载41:二月十日
  6. 工作学习资料备份记录
  7. 2016/1/14 java随机数生成
  8. 详解Nginx的功能策略配置
  9. 动态时间规整算法_如何使用动态时间规整算法进行语音识别
  10. 计算机重启后一直黑屏转圈,电脑win10开机黑屏转圈十几秒怎么解决
  11. (论文)Persuading Customers to Buy Early: The Value of Personalized
  12. 针对传感网的数据管理系统结构有_2010年自考管理信息系统模拟试题及答案(三)...
  13. 如何做好App性能测试
  14. 基于图搜索的规划算法之Voronoi图法
  15. sql server 替换字段中的部分字符,替换指定字符的方法
  16. 谷歌浏览器双击打不开pdf问题
  17. 解决Worker 1 failed executing transaction ‘ANONYMOUS‘ at master log mall-mysql-bin.000001, end_log_pos
  18. Watir vs. SilkTest
  19. pip is not an internal or external command how to solve pip 不是内部或外部命令 ------解决方法 顺便把pip升级
  20. 推动长三角信创产业发展 华云数据承办的“十四五”规划系列座谈会信创专场顺利召开

热门文章

  1. 微信小程序----返回上一页刷新或当前页刷新
  2. PDF怎么用免费软件转换成word?推荐个高性价比转换方法
  3. 华清远见-重庆中心-HTML、CSS技术总结
  4. 在家做什么小生意赚钱,这6种最适合在家操作!
  5. 一封超级牛的数据库程序员的情书表白
  6. 2022-2028全球与中国汽车软内饰材料市场现状及未来发展趋势
  7. php c端,蛋白测序(N端,C端测序)
  8. PHP微信防止token过期,微信调用接口,防止Access_token过期的方法
  9. 搜狗老域名作用之快速大量搜狗收录
  10. 如何对智能对话机器人的智能化水平分类