首页 > 其他分享 >杭电2092

杭电2092

时间:2023-02-06 21:07:27浏览次数:32  
标签:乘起来 int 2092 整数 杭电 num 等于 include


整数解

Problem Description
有二个整数,它们加起来等于某个整数,乘起来又等于另一个整数,它们到底是真还是假,也就是这种整数到底存不存在,实在有点吃不准,你能快速回答吗?看来只能通过编程。
例如:
x + y = 9,x * y = 15 ? 找不到这样的整数x和y
1+4=5,1*4=4,所以,加起来等于5,乘起来等于4的二个整数为1和4
7+(-8)=-1,7*(-8)=-56,所以,加起来等于-1,乘起来等于-56的二个整数为7和-8

Input
输入数据为成对出现的整数n,m(-10000

# include <iostream>
# include <cstdio>
# include <cstring>
# include <cmath>

using namespace std;

int main(){

int n,m;
int t;

while(cin>>n>>m,n!=0||m!=0){
int num = n*n - 4*m;
t = sqrt(num);//判断是否是整数的方法
if(t*t==num){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
return 0;
}


标签:乘起来,int,2092,整数,杭电,num,等于,include
From: https://blog.51cto.com/u_15955675/6040490

相关文章

  • 杭电1048--输出输出格式控制
    TheHardestProblemEver​​http://acm.hdu.edu.cn/showproblem.php?pid=1048​​ProblemDescriptionJuliusCaesarlivedinatimeofdangerandintrigue.Thehar......
  • 杭电2086 A=?
    #include<iostream>#include<cstdio>usingnamespacestd;intmain(){intn,i,j;doublea[2],b[50000],k;while(cin>>n){cin>>a[0]>>a[1];for(i=0;i<n;i++){cin>>b[i];......
  • 杭电2086 A=? 与整数与浮点数是否相等
    A1=?ProblemDescription有如下方程:Ai=(Ai-1+Ai+1)/2-Ci(i=1,2,3,….n).若给出A0,An+1,和C1,C2,…..Cn.请编程计算A1=?Input输入包括多个测......
  • 杭电2084
    数塔在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经......
  • 杭电1171
    BigEventinHDUProblemDescriptionNowadays,weallknowthatComputerCollegeisthebiggestdepartmentinHDU.But,maybeyoudon’tknowthatComputerColl......
  • 杭电1339
    ASimpleTaskProblemDescriptionGivenapositiveintegernandtheoddintegeroandthenonnegativeintegerpsuchthatn=o2^p.ExampleForn=24,o=3and......
  • 杭电1335-任意进制的转换
    BasicallySpeaking​​http://acm.hdu.edu.cn/showproblem.php?pid=1335​​ProblemDescriptionTheReallyNeatoCalculatorCompany,Inc.hasrecentlyhiredyourt......
  • 杭电1407--暴力与优化
    测试你是否和LTC水平一样高ProblemDescription大家提到LTC都佩服的不行,不过,如果竞赛只有这一个题目,我敢保证你和他绝对在一个水平线上!你的任务是:计算方程x^2+y^2+z^2......
  • 杭电1114--完全背包
    Piggy-BankProblemDescriptionBeforeACMcandoanything,abudgetmustbepreparedandthenecessaryfinancialsupportobtained.Themainincomeforthisacti......
  • 杭电1266--数的倒叙
    ReverseNumberProblemDescriptionWelcometo2006’4computercollegeprogrammingcontest!Specially,Igivemybestregardstoallfreshmen!Youarethefuture......