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 ...
随机推荐
- spring Cloud负载均衡Ribbon
Ribbon饥饿加载 默认情况下Ribbon是懒加载的.当服务起动好之后,第一次请求是非常慢的,第二次之后就快很多. 解决方式:开启饥饿加载 ribbon: eager-load: enabled: ...
- 运行npm run start 提示primordials is not defined
下载https://github.com/ant-motion/editor-list 执行 npm install npm start gulp构建时报错. 原因:安装gulp版本与node版本不兼 ...
- @codeforces - 668E@ Little Artem and 2-SAT
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定两个 2-sat 问题,询问两个问题的解集是否相同. 如果不 ...
- Com训练_1
初次接触Com大概是2001年,离现在多年了,那时认识比较肤浅,再次接触学习下. //ComPort + D7, 稍后将训练ComPort6 + D10.3.2环境 //MSComm + D7,D10 ...
- LR字符串处理函数-lr_eval_string
char *lr_eval_string( const char *instring ); 主要返回参数的实际内容 Action() { web_save_timestamp_param(" ...
- 一文搞定Redis五大数据类型及应用场景
本文学习知识点 redis五大数据类型数据类型:string.hash.list.set.sorted_set 五大类型各自的应用场景 @TOC 1. string类型 1-1 string类型数据的 ...
- opencv Scalar
template<typename _Tp> class Scalar_ : public Vec<_Tp, 4> { public: //! various construc ...
- 黎活明8天快速掌握android视频教程--23_网络通信之网络图片查看器
1.首先新建立一个java web项目的工程.使用的是myeclipe开发软件 图片的下载路径是http://192.168.1.103:8080/lihuoming_23/3.png 当前手机和电脑 ...
- 07.Easymock的实际应用
第一步下载对应的java包添加到工程中 并静态导入所需要的j类 import static org.easymock.EasyMock.*; 这里有的注意点 package com.fjnu.serv ...
- 动态自动配置Bean
概览 接口Condition 用于基于条件的自动配置,和注解@Conditional配合使用,可实现JavaBean的动态自动配置 自定义实现动态配置Bean 定义一个接口和两个实现类 定义两个Con ...