有二个整数,它们加起来等于某个整数,乘起来又等于另一个整数,它们到底是真还是假,也就是这种整数到底存不存在,实在有点吃不准,你能快速回答吗?看来只能通过编程。
例如:
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<n,m<10000),它们分别表示整数的和与积,如果两者都为0,则输入结束。
Output
只需要对于每个n和m,输出“Yes”或者“No”,明确有还是没有这种整数就行了。
Sample Input
9 15
5 4
1 -56
0 0

Sample Output

No
Yes
Yes

#include <stdio.h>
#include<math.h>
int main()
{
int n, m;
while(scanf("%d%d", &n, &m)&& n+m)
{
double x = 1.0*(n+sqrt(n*n-4*m))/2;
double y = 1.0*(n-sqrt(n*n-4*m))/2; if(x == (int) x && y == (int)y)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}

#include<math.h>
#include<stdio.h>
int main()
{
int m,n;
while(scanf("%d%d",&m,&n)==2&&(n||m))
{
int flag=0;
if(n<0)
{
int n1=-n;
int i;
for(i=1;i<=n1;i++)
if(n1%i==0&&(i+n/i)==m)
{
flag=1;
break;
}
}
else if(n>0)
{
int i;
for(i=1;i<=n;i++)
if(n%i==0)
{
if((i+n/i)==m||(i+n/i)==-m)
{
flag=1;
break;
}
}
}
else if(n==0)
flag=1;
if(flag)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}

...

训练1-E的更多相关文章

  1. SSD框架训练自己的数据集

    SSD demo中详细介绍了如何在VOC数据集上使用SSD进行物体检测的训练和验证.本文介绍如何使用SSD实现对自己数据集的训练和验证过程,内容包括: 1 数据集的标注2 数据集的转换3 使用SSD如 ...

  2. 基于英特尔® 至强 E5 系列处理器的单节点 Caffe 评分和训练

    原文链接 在互联网搜索引擎和医疗成像等诸多领域,深度神经网络 (DNN) 应用的重要性正在不断提升. Pradeep Dubey 在其博文中概述了英特尔® 架构机器学习愿景. 英特尔正在实现 Prad ...

  3. 记一周cdqz训练

    #include <cstdio> using namespace std; int main(){ puts("转载请注明出处:http://www.cnblogs.com/w ...

  4. 语言模型kenlm的训练及使用

    一.背景 近期研究了一下语言模型,同事推荐了一个比较好用的工具包kenlm,记录下使用过程. 二.使用kenlm训练 n-gram 1.工具介绍:http://kheafield.com/code/k ...

  5. LUA中将未分类数据分为测试集和训练集

    require 'torch' require 'image' local setting = {parent_root = '/home/pxu/image'} function list_chil ...

  6. HDU-SupportOrNot训练实录

    菜鸡队训练实录. 现场赛记录: 2016:[名称:奖项/排名] ZJPSC:Gold/1 CCPC中南邀请赛:Gold/1 ICPC Dalian:Gold/24 ICPC Beijing:Gold/ ...

  7. [转]Tesseract 3.02中文字库训练

    下载chi_sim.traindata字库下载tesseract-ocr-setup-3.02.02.exe 下载地址:http://code.google.com/p/tesseract-ocr/d ...

  8. codefordream 关于js中级训练

    中级训练接着就紧锣密鼓的开始了. 首先是关于变量,变量的作用是给一个数据值标注名称. 注:JavaScript中变量名,函数名,参数名的命名规范:至少由字母,下划线,美元符号,数字其中的一种组成,但不 ...

  9. codefordream 关于js初级训练

    这里的初级训练相对简单,差不多都是以前知识温习. 比如输出“hello world”,直接使用console.log()就行.注释符号,“//”可以注释单行,快捷键 alt+/,"/*   ...

  10. svm训练显示信息说明

    现简单对屏幕回显信息进行说明: #iter 为迭代次数, nu  与前面的操作参数 -n nu  相同, obj 为 SVM 文件转换为的二次规划求解得到的最小值, rho  为判决函数的常数项 b  ...

随机推荐

  1. D - Mayor's posters

    D - Mayor's posters POJ - 2528 思路:线段树+离散化. 离散化时注意特殊情况,如果两个数相差大于一,离散时也应该差1.比如 1 3 离散后应该为 1 2. 错因: 1.二 ...

  2. UVA - 348Optimal Array Multiplication Sequence(递推)

    id=19208">题目:Optimal Array Multiplication Sequence 题目大意:给出N个矩阵相乘.求这些矩阵相乘乘法次数最少的顺序. 解题思路:矩阵相乘 ...

  3. python3字符编码错误

    在3.x 这里返回的是bytes-like类型, 所以这里不需要释放编码 ,释放也没有意义, 而是应该encode 转换成我们需要的编码, 之所会造成类型错误,原因是就在这里. 他们返回的类型不一样, ...

  4. [Cypress] Find and Test Focused Input with Chrome’s DevTools in Cypress

    In this lesson, we’ll add tests that finds a focused input. We’ll use Chrome’s dev tools from inside ...

  5. 命令行使用Eclipse的debug签名失败“找不到 xx.keystore证书链”

    1.debug签名位置 2.查看debug.keystore具体信息 3.使用命令行签名 注意:debug签名password为android 4.出错原因是签名的别名写错,应为androiddebu ...

  6. linux命令用来查看日志关键字

    1.查看日志 前 n行: cat 文件名 | head -n 数量 demo: cat  test.log | head -n 200 # 查看test.log前200行 2.查看日志 尾 n行: c ...

  7. 求int型数据在内存中存储时1的个数

    1.求int型数据在内存中存储时1的个数 输入一个int型数据,计算出该int型数据在内存中存储时1的个数. 我们非常easy想到例如以下方法: #include <iostream> u ...

  8. Oracle学习(十二):存储过程/存储函数

    1.知识点 --第一个存储过程 /* 打印Hello World create [or replace] PROCEDURE 过程名(參数列表) AS PLSQL子程序体: 调用存储过程: 1. ex ...

  9. iOS10 推送通知详解(UserNotifications)

    iOS10新增加了一个UserNotificationKit(用户通知框架)来整合通知相关的API,UserNotificationKit框架增加了很多令人惊喜的特性: 更加丰富的推送内容:现在可以设 ...

  10. DNS隧道工具使用 不过其网络传输速度限制较大

    DNS隧道工具使用 http://www.freebuf.com/sectool/112076.html http://netsec.ccert.edu.cn/zhengming/2011/11/01 ...