题目连接

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的更多相关文章

  1. HDU 5224 Tom and paper(最小周长)

    HDU 5224 Tom and paper(最小周长) Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d &a ...

  2. hdu 5224 Tom and paper 水题

    Tom and paper Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/6 ...

  3. c.Tom and paper

    Tom and paper Description There is a piece of paper in front of Tom, its length and width are intege ...

  4. hdu 5225 Tom and permutation(回溯)

    题目链接:hdu 5225 Tom and permutation #include <cstdio> #include <cstring> #include <algo ...

  5. Tom and paper

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5224 题意: 给出矩形的面积,求出最小的周长. 样例: Sample Input 3 2 7 12   ...

  6. 组合数(Lucas定理) + 快速幂 --- HDU 5226 Tom and matrix

    Tom and matrix Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=5226 Mean: 题意很简单,略. analy ...

  7. Problem C HDU 5224

    Description There is a piece of paper in front of Tom, its length and width are integer. Tom knows t ...

  8. 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 < ...

  9. BestCoder Round #40

    T1:Tom and pape (hdu 5224) 题目大意: 给出一个矩形面积N,求周长的最小值.(长&&宽&&面积都是正整数) N<=109 题解: 没啥好 ...

随机推荐

  1. json 和 pickel 详解

    一.json json,用于字符串 和 python数据类型间进行转换 Json模块提供了四个功能:dumps.dump.loads.load 1.json.loads()用于将字符串形式的字典,列表 ...

  2. eclipse 弹出智能提示、代码自动换行

    在eclipse 中编写java 程序时,为了快速查找变量或搜索方法调用,在智能窗口的帮助下,程序的编写速度会更快,但eclipse 默认下并不弹出智能窗口,这就需要自己进行配置,设置的步骤如下: 打 ...

  3. android ios 只能輸入數字 不能輸入小數點的 函數 cordova

    andriod function numericsonly(ob) { var invalidChars = /[^0-9]/gi if (invalidChars.test(ob.value)) { ...

  4. PHP获取今天、昨天、明天的日期

    <?php echo "今天:".date("Y-m-d")."<br>"; echo "昨天:".d ...

  5. 【MySQL】DNS与MHA/ZABBIX构建的高可用MySQL

    MySQL实例组与DNS和MHA/ZABBIX架构示意图: DNS搭建:http://www.cnblogs.com/jiangxu67/p/4801230.html MHA分析:http://www ...

  6. WP8_区分滑动和点击(在图片列表中)

    在windows phone中,对于一个页面中 有图片列表的,滑动的时候,很容易被误认为是点击了图片,而打开图片详细信息等,原意是滑动列表,由此对图片添加2个事件,来控制其点击行为(滑动的时候,基本不 ...

  7. SQL2005中使用identity_insert向自动增量字段中写入内

    摘自: http://www.aspbc.com/tech/showtech.asp?id=1117 SQL2005以前的数据库是不允许向自动增量字段中写入内容的,ACCESS也不行,但在SQL200 ...

  8. java中使用mysql

    executeUpdate:是最基础的数据库的更新.插入和删除操作.效率低下.executeQuery:是最基础的执行查询语句,同样也是效率低下.execute:兼具上面二者的功能但返回一个boole ...

  9. jQuery bind and unbind (绑定和解除)

    测试:页面代码: <body> <input type="button" name="aaa" value="点击我"&g ...

  10. Ado.net利用反射执行SQL得到实体

    public Model.orderParent GetTraceIDforID(string orderid) { string sql = string.Format(" select ...