题目:

分析:

  看到式子,推一推其实就是(y+x)*(y-x)=n,显然可以根号n的枚举,判断一下合不合法直接出结果,然后就是代码。注意x!=0.

#include <cstdio>
#include <string>
using namespace std;
int main(){
int t;
scanf("%d",&t);
for(int i=;i<=t;i++){
int n;
scanf("%d",&n);
int ans=1e9;
for(int i=;i*i<n;i++){
if(n%i||(i+n/i)%)
continue;
ans=min(ans,(n/i-i)/);
}
printf("%d\n",ans>=1e9-?-:ans);
}
return ;
}

A Simple Problem,题解的更多相关文章

  1. HDU 4143 A Simple Problem 题解

    题目 For a given positive integer n, please find the saallest positive integer x that we can find an i ...

  2. POJ 3468 A Simple Problem with Integers(线段树 成段增减+区间求和)

    A Simple Problem with Integers [题目链接]A Simple Problem with Integers [题目类型]线段树 成段增减+区间求和 &题解: 线段树 ...

  3. Poj 3468-A Simple Problem with Integers 线段树,树状数组

    题目:http://poj.org/problem?id=3468   A Simple Problem with Integers Time Limit: 5000MS   Memory Limit ...

  4. A Simple Problem with Integers(100棵树状数组)

    A Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  5. 【POJ】3468 A Simple Problem with Integers ——线段树 成段更新 懒惰标记

    A Simple Problem with Integers Time Limit:5000MS   Memory Limit:131072K Case Time Limit:2000MS Descr ...

  6. A Simple Problem with Integers(线段树,区间更新)

    A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 83822   ...

  7. 3212: Pku3468 A Simple Problem with Integers

    3212: Pku3468 A Simple Problem with Integers Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 1053  So ...

  8. A Very Simple Problem

    A Very Simple Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...

  9. HDU 4267 A Simple Problem with Integers 多个树状数组

    A Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  10. poj 3468 A Simple Problem with Integers 线段树区间加,区间查询和

    A Simple Problem with Integers Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://poj.org/problem?i ...

随机推荐

  1. Tidyverse| XX_join :多个数据表(文件)之间的各种连接

    本文首发于公众号:“生信补给站” Tidyverse| XX_join :多个数据表(文件)之间的各种连接 前面分享了单个文件中的select列,filter行,列拆分等,实际中经常是多个数据表,综合 ...

  2. HashMap源码解析(java1.8.0)

    1.1 背景知识 1.1.1 红黑树 二叉查找树可能因为多次插入新节点导致失去平衡,使得查找效率低,查找的复杂度甚至可能会出现线性的,为了解决因为新节点的插入而导致查找树不平衡,此时就出现了红黑树. ...

  3. (一)linux三剑客之grep

    给自己提出以下6个问题,看自己是否真正掌握了grep [1] grep 是什么? [2] grep 有什么作用 ? [4] grep 常用于何处 ? [5] grep 的基本用法 ? [6] grep ...

  4. Node第三方模块

    node第三方模块集合 1.nrm 切换npm下载的镜像地址 nrm ls   查看可用镜像 nrm use +镜像名 2.nodemon 在控制台nodenom替代node命令执行nodejs文件, ...

  5. 带你轻松了解C# Lock 关键字

    相信绝大多数.NET玩家和我一样,常常使用Timer这个对象,而在WPF中使用DispatcherTimer的人也是很多,DispatcherTimer是在UI线程跑的.我们的程序中大多数都会充斥很多 ...

  6. 搜索相关性算法在 DiDi Food 中的搜索

    导读:今天给大家分享的主题是搜索匹配问题在 DiDi Food 中的一些探索与应用.本文首先介绍了搜索相关性的一些背景,之后介绍了业界常见的三种匹配模型,以及在DiDi Food业务中的模型效果对比. ...

  7. 1.Go 开始搞起

    link 1. IDE Go Land 服务器激活 2. 资源 中文网站 翻译组 翻译组wiki 待认领文章 入门指南 中文文档 fork 更新 github 中如何定期使用项目仓库内容更新自己 fo ...

  8. 【请帮帮我】为什么www.52pjb.net总是不收录,最多只收录首页?

    做的好多个网站百度搜索都百度收录了,可是在其中一个一直不百度收录?http://www.52pjb.net,求大神帮忙看看,很着急很着急

  9. Mini2440上的第一个程序——点亮Led

    手头的Mini2440搁置了两年半之后,我再次决定拿出它,重新尝试嵌入式Linux的学习. 我使用的是友善之臂的Mini2440开发板.韦东山的<嵌入式Linux应用开发完成手册>及其视频 ...

  10. 面试:在面试中关于List(ArrayList、LinkedList)集合会怎么问呢?你该如何回答呢?

    前言 在一开始基础面的时候,很多面试官可能会问List集合一些基础知识,比如: ArrayList默认大小是多少,是如何扩容的? ArrayList和LinkedList的底层数据结构是什么? Arr ...