D - Find Integer

$a^{n}+b^{n}=c^{n}$

给定a,n求解$b,c$

三次以上没有整数解

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll A[];
ll n,a;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lld%lld",&n,&a); if(n>=)
{
puts("-1 -1");
}
else if(n==)
{
cout<<<<' '<<a+<<'\n';
}
else if(n==)
{
cout<<-<<' '<<-<<'\n';
}
else
{
ll b,c,x,y;
for(ll i=; i<a; i++)
{
if((a*a)%i==)
{
x=(a*a)/i;
y=i;
// cout<<(x+y)<<" "<<a<<endl;
if((x+y)%==&&(x+y)!=(*a))break;
}
}
c=(x+y)/;
b=sqrt(c*c-a*a);
cout<<b<<' '<<c<<'\n';
}
}
}

D - Find Integer的更多相关文章

  1. LeetCode 7. Reverse Integer

    Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you ...

  2. Integer.parseInt 引发的血案

    Integer.parseInt 处理一个空字符串, 结果出错了, 程序没有注意到,搞了很久, 引发了血案啊!! 最后,终于 观察到了, 最后的部分: Caused by: java.lang.NoC ...

  3. 由一个多线程共享Integer类变量问题引起的。。。

    最近看到一个多线程面试题,有三个线程分别打印A.B.C,请用多线程编程实现,在屏幕上循环打印10次ABCABC- 看到这个题目,首先想到的是解决方法是定义一个Integer类对象,初始化为0,由3个线 ...

  4. [LeetCode] Integer Replacement 整数替换

    Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2. If ...

  5. [LeetCode] Integer Break 整数拆分

    Given a positive integer n, break it into the sum of at least two positive integers and maximize the ...

  6. [LeetCode] Integer to English Words 整数转为英文单词

    Convert a non-negative integer to its english words representation. Given input is guaranteed to be ...

  7. [LeetCode] Roman to Integer 罗马数字转化成整数

    Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...

  8. [LeetCode] Integer to Roman 整数转化成罗马数字

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  9. [LeetCode] String to Integer (atoi) 字符串转为整数

    Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...

  10. [LeetCode] Reverse Integer 翻转整数

    Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to ...

随机推荐

  1. [LeetCode] 1092. Shortest Common Supersequence

    LeetCode刷题记录 传送门 Description Given two strings str1 and str2, return the shortest string that has bo ...

  2. Canvas入门05-渐变颜色

    线性渐变API: ctx.createLinearGradient(double x1, double y1, double x2, double y2) 创建一个渐变实例 (x1, y1) 渐变的起 ...

  3. 工作笔记之:如何在eclipse安装CVS插件?找了很久的,自己总结一下

    (1)在主目录里“help”→Install New Software.....→The Eclipse Project Updates - http://download.eclipse.org/e ...

  4. Text Autosizer&&解决移动端网页文本字体怪异增大问题

    在做移动端页面时,有时你设置了字体大小,有的部分即使设置了行内样式也不生效,而有些显示正常,这个特性就是Text Autosizer在搞鬼. 以下是解决方案: ①给元素设置 -webkit-text- ...

  5. 剑指offer-用两个栈来实现一个队列-队列与栈-python

    用两个栈来实现一个队列,完成队列的Push和Pop操作. 队列中的元素为int类型. 思路:使用两个栈,stackA 用来接收node stackB 用来接收 stackA 的出栈 # -*- cod ...

  6. tabcontrol动态生成选项卡,并且在选项卡中添加窗体

    http://blog.csdn.net/zx13525079024/article/details/6084733 今天在论坛上看到有人问到,如果在点击TRVEVIEW时动态生成tabcontrol ...

  7. Laravel 学习笔记之数据库操作——Eloquent ORM

    1. 时间戳 默认情况下在使用ORM操作数据库进行添加.修改数据时, created_at 和 updated_at列会自动存在于数据表中,并显示的是 ‘2017’格式,如果想以 Unix时间戳格式存 ...

  8. Postgresql重安装报错The database cluster initialisation failed.

    之前安装过PostgreSQL-9.6.5,卸载后,重装PostgreSQL-9.1.3版本,报错. 清除注册表,删除postgres账户,清除垃圾后,再次安装仍然报错. 最后改变默认安装路径,神奇的 ...

  9. xcode自动生成代码片段

    一.什么是代码片段 当在Xcode中输入dowhile并回车后,Xcode会出现下图所示的提示代码: 这就是代码片段,目的是使程序员以最快的速度输入常用的代码片段,提高编程效率.该功能是从Xcode4 ...

  10. Out of memory: Kill process 25280 (php-fpm) score 86 or sacrifice child

    php-fpm 耗尽服务器内存的办法 java服务今天突然宕机,通过 cat /var/log/messages进行查看,发现是系统内存溢出导致系统把java的进程杀掉了 使用top查看系统内存使用情 ...