hdu 5224 Tom and paper
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5224
Tom and paper
Description
There is a piece of paper in front of Tom, its length and width are integer. Tom knows the area of this paper, he wants to know the minimum perimeter of this paper.
Input
In the first line, there is an integer T indicates the number of test cases. In the next T lines, there is only one integer n in every line, indicates the area of paper.
$T\leq 10,n\leq {10}^{9}$
Output
For each case, output a integer, indicates the answer.
Sample Input
3
2
7
12
Sample Output
6
16
14
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
using std::min;
using std::cin;
using std::cout;
using std::endl;
using std::find;
using std::sort;
using std::map;
using std::pair;
using std::vector;
using std::multimap;
#define pb(e) push_back(e)
#define sz(c) (int)(c).size()
#define mp(a, b) make_pair(a, b)
#define all(c) (c).begin(), (c).end()
#define iter(c) decltype((c).begin())
#define cls(arr,val) memset(arr,val,sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
const int Max_N = ;
const int INF = ~0u >> ;
typedef unsigned long long ull;
void solve(int n) {
int ans = INF;
for (int i = ; (ull)i * i <= n; i++) {
if (n % i == ) ans = min(ans, (i + n / i) << );
}
printf("%d\n", ans);
}
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int t, n;
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
solve(n);
}
return ;
}
hdu 5224 Tom and paper的更多相关文章
- HDU 5224 Tom and paper(最小周长)
HDU 5224 Tom and paper(最小周长) Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d &a ...
- hdu 5224 Tom and paper 水题
Tom and paper Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/6 ...
- c.Tom and paper
Tom and paper Description There is a piece of paper in front of Tom, its length and width are intege ...
- hdu 5225 Tom and permutation(回溯)
题目链接:hdu 5225 Tom and permutation #include <cstdio> #include <cstring> #include <algo ...
- Tom and paper
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5224 题意: 给出矩形的面积,求出最小的周长. 样例: Sample Input 3 2 7 12 ...
- 组合数(Lucas定理) + 快速幂 --- HDU 5226 Tom and matrix
Tom and matrix Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=5226 Mean: 题意很简单,略. analy ...
- Problem C HDU 5224
Description There is a piece of paper in front of Tom, its length and width are integer. Tom knows t ...
- HDU 5226 Tom and matrix(组合数学+Lucas定理)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5226 题意:给一个矩阵a,a[i][j] = C(i,j)(i>=j) or 0(i < ...
- BestCoder Round #40
T1:Tom and pape (hdu 5224) 题目大意: 给出一个矩形面积N,求周长的最小值.(长&&宽&&面积都是正整数) N<=109 题解: 没啥好 ...
随机推荐
- 使用Flex4的PopUpManager的addPopUp() 方法弹出 removeChild异常的解决办法
Flex4中,弹出窗口有两种: Alert.show("balabalabala-"); PopUpManager.addPopUp([要弹出的控件],[父控件],[是否模态] ...
- kubernetes学习笔记1
安装篇 Downloading Kubernetes You can either build a release from sources or download a pre-built relea ...
- 架构设计--逻辑层 vs 物理层
如果你对项目管理.系统架构有兴趣,请加微信订阅号"softjg",加入这个PM.架构师的大家庭 Layer 和Tier都是层,但是他们所表现的含义不同,Tier指的是软件系统中物理 ...
- java.lang.IllegalArgumentException
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.Persiste ...
- Sql语句直接返回XML文件
通过Sql语句直接返回XML文件 select UserID,UserName,AccountName,LoginPassword from users for xml raw('Users') ,r ...
- C#中DataTable转换JSON
#region 将DataTable转换为json public string dt2json(DataTable dt) { JavaScriptSerializer jss = new JavaS ...
- cordova ios --->OC 调用 js (一)
1.在HTML中定义一个函数如OCcallJS() function OCcallJS(){ alert("OC 调用js 的 方法"); } 2.当webview 加载完成的时候 ...
- pyrrd 程序
http://elekslabs.com/2013/12/rrd-and-rrdtool-sar-graphs-using-pyrrd.html http://thepiandi.blogspot.j ...
- android从资源文件中读取文件流显示
在android中,假如有的文本文件,比如TXT放在raw下,要直接读取出来,放到屏幕中显示,可以这样:代码区: private void doRaw(){ InputStream is = this ...
- 关于使用SVN update时出现:E155004错误
今天早上到公司开了电脑,准备update下SVN的代码,但是在update时出现svn: E155004: Working copy 'E:\XX' locked 错误,乍眼一看以为是什么配置出错, ...