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 题解: 没啥好 ... 
随机推荐
- 慕课网-安卓工程师初养成-4-4 Java条件语句之嵌套 if
			来源:http://www.imooc.com/code/1356 嵌套 if 语句,只有当外层 if 的条件成立时,才会判断内层 if 的条件.例如,活动计划的安排,如果今天是工作日,则去上班,如果 ... 
- 第三方框架之SDWebImage
			1. 下载SDWebImage,导入工程.github托管地址https://github.com/rs/SDWebImage 2. 在需要的地方导入头文件#import "UIImageV ... 
- CSS3之选择器
			总结了下CSS3新增的一些选择器. CSS3的选择器有基本选择器.属性选择器.伪类选择器几类. CSS3选择器 选择器 举例 例子描述 element1~element2 p~a 选择前面有 < ... 
- 蛮考验基础的JS笔试题(有坑小心!)
			1. 考察this var length = 10 function fn(){ alert(this.length) } var obj = { length: 5, method: functi ... 
- Windows API——CREATEEVENT——创建事件
			事件是一个允许一个线程在某种情况发生时,唤醒另外一个线程的同步对象.事件告诉线程何时去执行某一给定的任务,从而使多个线程流平滑 CreateEvent是创建windows事件的意思,作用主要用在判断线 ... 
- 在AX4.0中使用C#脚本的实现
			1,虽然ms收购了ax,但是在ax低版本(ver<=4.0)中,还没有办法直接使用ms现在主推的.net技术. 通常的做法是现在AX中天津.net的引用,然后才能在代码中使用.net的一些对象以 ... 
- leetcode 8
			string类型转换为int类型,需要考虑不同的转换情况. “ 04” 转换结果 4: “ 4 43” 转换结果 4: “a@12 ” 转换结果 0: “12a” ... 
- Android IOS WebRTC 音视频开发总结(三四)-- windows.20150706
			最近好不容易更新了PC版的WEBRTC,总结下有哪些调整,文章来自博客园RTC.Blacker,支持原创,转载请说明出处. 图1:解决方案工程结构对比: 说明: 1, 最大的调整就是移除了VideoE ... 
- 一款非常简单的android音乐播放器源码分享给大家
			一款非常简单的android音乐播放器源码分享给大家,该应用虽然很小,大家常用的播放器功能基本实现了,可能有点还不够完善,大家也可以自己完善一下,源码在源码天堂那里已经有了,大家可以到那里下载学习吧. ... 
- ctags对部分目录生成tags
			最近在研究Tiny6410上的uboot移植,看uboot源码时,生成tags文件用的是最粗暴的方法:“ctags -R *”,由于某些函数在各个平台下都有实现,导致在用“g+]”跳转到该函数的定义时 ... 
