链接:HDU - 6441

题意:已知 n,a,求 b,c 使 a^n + b^n = c^n 成立。

题解:费马大定理

1.a^n + b^n = c^n,当 n > 2 时无解;

2.

当 a 为奇数

a = 2 * k + 1;

c = k ^ 2 + (k + 1) ^ 2;

b = c - 1;

当 a 为偶数

a = 2 * k + 2;

c = 1 + (k + 1) ^ 2;

b = c - 2;

#include <bits/stdc++.h>
using namespace std; const double EPS = 1e-;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + ;
const int maxn = 1e5 + ;
long long n, a, b, c; int main()
{
int T;
scanf("%d", &T);
while(T--){
scanf("%lld%lld", &n, &a); if(n == || n > ){
puts("-1 -1");
continue;
} if(n == ){
printf("%lld %lld\n", a, a<<);
continue;
} if(a & 1LL){
long long k = a / ;
c = k * k + (k + ) * (k + );
b = c - ;
}
else{
long long k = a / - ;
c = + (k + ) * (k + );
b = c - ;
} printf("%lld %lld\n", b, c);
} return ;
}

HDU - 6441(费马大定理)的更多相关文章

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

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

  2. HDU 6441 费马大定理+勾股数

    #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se ...

  3. HDU 6441 - Find Integer - [费马大定理][2018CCPC网络选拔赛第4题]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6441 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...

  4. hdu 6441 Find Integer(费马大定理+勾股数)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6441(本题来源于2018年中国大学生程序设计竞赛网络选拔赛) 题意:输入n和a,求满足等式a^n+b^ ...

  5. 题解报告:hdu 6441 Find Integer(费马大定理+智慧数)

    Problem Description people in USSS love math very much, and there is a famous math problem .give you ...

  6. 水题两篇 Dream & Find Integer (HDU 6440/6441)

    // 出自ICPC 2018网络赛C - Dream & D - Find Integer // 对大佬来讲的水题,本菜鸡尽量学会的防爆零题... // 今晚翻看vjudge昨日任务上的C题, ...

  7. 【2018 CCPC网络赛】1004 - 费马大定理&数学

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6441 Knowledge Point: 1. 费马大定理:当整数n >2时,关于x, y, z的 ...

  8. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  9. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

随机推荐

  1. HDU 1207 汉诺塔II (找规律,递推)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1207 汉诺塔II Time Limit: 2000/1000 MS (Java/Others)     ...

  2. java ssm 后台框架平台 项目源码 websocket IM quartz springmvc

    A代码编辑器,在线模版编辑,仿开发工具编辑器,pdf在线预览,文件转换编码B 集成代码生成器 [正反双向](单表.主表.明细表.树形表,快速开发利器)+快速表单构建器freemaker模版技术 ,0个 ...

  3. Knowledge Point 20180308 拔下forEach的外衣

    剖析加强for 很长一段时间对于foreach都有一种误解,那就是foreach只是普通for的包装,底层还是普通for循环,直到深入了解迭代器的时候,才发现自己错了,本节就来探讨一下foreach, ...

  4. MyBatis-Plus工具快速入门使用

    MyBatis-plus有什么特色 1.代码生成 2.条件构造器 对我而言,主要的目的是使用它强大的条件构建器. 快速使用步骤: 1.添加pom文件依赖 <dependency> < ...

  5. app后端api设计【转】

    博客:https://blog.csdn.net/newjueqi/article/details/44037011 app和后端的交互,一般都是通过后端提供的api实现.api的设计,估计很多刚进入 ...

  6. Jboot使用appassembler-maven-plugin插件生成启动脚本

    appassembler-maven-plugin介绍: 使用appassembler-maven-plugin插件可自动生成跨平台的启动脚本,可省去手工写脚本的麻烦,而且还可以生成jsw的后台运行程 ...

  7. 基于jquery,ajax请求及自我终止的函数封装。

    场景描述: 在我们平时的开发过程中,经常会遇到这样的情况.在搜索功能中进行模糊搜索或者联想关联. 这就要我们每次对输入框中的数据进行改动时,都要发送一次请求.当在短时间内多次操作改动时,问题就出现了. ...

  8. 3D立方体

    效果图 主要用到的3D属性 1.保留子元素的3d属性:transform-style:preserve-3d; 2.2D变形属性: ①transform:translate()平移,分X轴,Y轴,Z轴 ...

  9. Python写网络后台脚本

    Python写网络后台脚本. 首先安装Python3.6.5,在centos中自带的Python是2.6版本的,现在早就出现了3.6版本了况且2和3 之间的差距还是比较大的,所以我选择更新一下Pyth ...

  10. Kylin 几个sql报错原因 汇总

    Can't create EnumerableAggregate! while executing SQL由distinct count引起的错误 null while executing SQLjo ...