A Simple Problem,题解
题目:

分析:
看到式子,推一推其实就是(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,题解的更多相关文章
- HDU 4143 A Simple Problem 题解
题目 For a given positive integer n, please find the saallest positive integer x that we can find an i ...
- POJ 3468 A Simple Problem with Integers(线段树 成段增减+区间求和)
A Simple Problem with Integers [题目链接]A Simple Problem with Integers [题目类型]线段树 成段增减+区间求和 &题解: 线段树 ...
- Poj 3468-A Simple Problem with Integers 线段树,树状数组
题目:http://poj.org/problem?id=3468 A Simple Problem with Integers Time Limit: 5000MS Memory Limit ...
- A Simple Problem with Integers(100棵树状数组)
A Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K ...
- 【POJ】3468 A Simple Problem with Integers ——线段树 成段更新 懒惰标记
A Simple Problem with Integers Time Limit:5000MS Memory Limit:131072K Case Time Limit:2000MS Descr ...
- A Simple Problem with Integers(线段树,区间更新)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 83822 ...
- 3212: Pku3468 A Simple Problem with Integers
3212: Pku3468 A Simple Problem with Integers Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1053 So ...
- A Very Simple Problem
A Very Simple Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- HDU 4267 A Simple Problem with Integers 多个树状数组
A Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K ...
- 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 ...
随机推荐
- 08_提升方法_AdaBoost算法
今天是2020年2月24日星期一.一个又一个意外因素串连起2020这不平凡的一年,多么希望时间能够倒退.曾经觉得电视上科比的画面多么熟悉,现在全成了陌生和追忆. GitHub:https://gith ...
- (十一)DVWA全等级SQL Injection(Blind)盲注--手工测试过程解析
一.DVWA-SQL Injection(Blind)测试分析 SQL盲注 VS 普通SQL注入: 普通SQL注入 SQL盲注 1.执行SQL注入攻击时,服务器会响应来自数据库服务器的错误信息,信息提 ...
- MySQL 8.0权限认证(下)
MySQL 8.0权限认证(下) 一.设置MySQL用户资源限制 通过设置全局变量max_user_connections可以限制所有用户在同一时间连接MySQL实例的数量,但此参数无法对每个 ...
- 常见ie9兼容问题
公司项目要求需要兼容ie9,开发过程中遇到了许多问题,在这里记录一下,希望可以帮到其他需要的小伙伴. 浏览器兼容性问题无外乎三点,css样式兼容.JavaScript兼容及h5部分标签的兼容.主要介绍 ...
- vscode 修改标签栏样式为换行全部展示
目前vscode的标签栏是滚动式的,选择查看都不是很方便,于是想要搞成andriod studio那种换行全部展示的标签栏. 因为vscode是electron写的,因此修改css就可以实现. 修改方 ...
- git push 错误,回滚 push操作
作者:故事我忘了¢个人微信公众号:程序猿的月光宝盒 0.记一次使用git push后,覆盖了同事代码的糗事 前言: 都在WebStorm中操作,Idea或者PyCharm同理 为了高度还原尴尬 ...
- Nice Jquery Validator 常用规则整理
一些简单规则 numeric: [/^[0-9]*$/, '请填写数值'], money: [/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/, "请填写有效的金额" ...
- Java中容易遗漏的小知识点( 一 )(为了和小白一样马上要考试的兄弟准备的,希望小白和大家高过不挂)
笔者csdn博客同文地址:https://blog.csdn.net/weixin_45791445/article/details/106597515 我是小康小白,一个平平无奇的Java小白.热爱 ...
- (一)Log4j使用
原文链接:https://www.jianshu.com/p/eb4ac2571c94?tdsourcetag=s_pctim_aiomsg 1.先创建个maven项目,在我们项目的pom文件中导入l ...
- mysql字符串类型(TEXT 类型)
TEXT 类型 TEXT 列保存非二进制字符串,如文章内容.评论等.当保存或查询 TEXT 列的值时,不删除尾部空格. TEXT 类型分为 4 种:TINYTEXT.TEXT.MEDIUMTEXT 和 ...