HDUOJ 6441 Find Integer

题目链接

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=cna^n+b^n=c^nan+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>2n>2n>2 时,一定无正整数解~
当 n=0n=0n=0 时,显然无解~
当 n=1n=1n=1 时,输出 111 和 a+1a+1a+1 即可
当 n=2n=2n=2 时,注意题目限定必须是正整数,我们考虑分奇偶,对 aaa 为奇数,a2a^2a2 可以拆分成 a2∗1a^2*1a2∗1;对 aaa 为偶数,a2a^2a2 可以拆分成 a22∗2\frac{a^2}{2}*22a2​∗2,分别解一个二元一次方程即可~
注意输出的顺序,AC代码如下:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int T,n,a;
int main(){scanf("%d",&T);while(T--){scanf("%d%d",&n,&a);if(n>2||n==0) printf("-1 -1\n");else if(n==2){if(a%2) printf("%d %d\n",(a*a-1)/2,(a*a+1)/2);else printf("%d %d\n",a*a/4-1,a*a/4+1);}else if(n==1){printf("1 %d\n",a+1);}}return 0;
}

HDUOJ 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(费马大定理)

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

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

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

  6. HDU 6441 Find Integer

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

  7. 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, ...

  8. HDU CCPC网络选拔赛 6441 Find Integer(数学)

    费马大定理只只有n=1或n=2时候才会有解 当n=2时,即满足勾股定理 一, 直角三角形a^2+b^2=c^2的a值奇偶数列法则: 定理1. 如a^2+b^2=c^2是直角三角形的三个整数边长,则必有 ...

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

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

最新文章

  1. html5简单游戏案例,HTML5存储(带一个粗糙的打怪小游戏案例)
  2. 通过iframe引入另外一个项目中的html片段到项目中,解决样式,高度,兼容等问题的策略
  3. Homework 8 测试计划
  4. Hyperledger Fabric 实战(七):链码 shim API 详解
  5. 简单的文本文件加密小程序
  6. 李迅雷:大城市化和居民加杠杆能支撑房价多久
  7. vue公式编辑器 加强版(简化版)
  8. 计算机时代汉字书写有了新的方式,网络时代的汉字书写
  9. 机器人关节控制硬件知识——伺服电机、驱动器、控制器
  10. 基于FPGA的UART串口通信实验(VHDL语言实现)
  11. 交叉编译arm版linaro-1.13.1-4.7-2013.03
  12. ubuntu 网速测试方法
  13. iOS 12+ ReplayKit 系统录屏(一)
  14. 云和恩墨亮相CNCC 2020,zCloud打造国产时代数据库管理中台
  15. unity如何改变重力方向
  16. 马士兵学习笔记-Java基础网络编程
  17. 如何加强幼儿园安全管理
  18. Android中实现平铺图片
  19. win7企业版安装vmtool提示无法进行,需要更新到SP1。【不换镜像,已解决】
  20. Win7、windows 2008 IIS7.5下载安装方法以及教程 IIS7配置PHP环境图文教程(fastcgi快速最新版)

热门文章

  1. 给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。
  2. HEVC亮度分量帧内预测模式代码详解
  3. 阿里巴巴给我们的启示--个人评论
  4. php面试题和答案整理
  5. ​【​观察】云栖大会共话JDM模式 揭秘创新背后的价值和启示
  6. 全面认识思科系列交换机型号
  7. C++学习——如何在C++中把map存入一个txtx文件
  8. js逆向破解 —— 懂车帝视频链接
  9. java导出word纸张方向_java导出word的几种方式
  10. python 环境配置