HDU 5224 Tom and paper(最小周长)

Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

 

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<=10,n<= 10^9
 

Output

For each case, output a integer, indicates the answer.
 

Sample Input

3
2
7
12
 

Sample Output

6
16
14
 
 
 
题解:给出面积求最小周长问题,数学问题
 
AC代码
#include<cstdio>
#include<cmath>
int main()
{
int t,s,n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&s);
n=(int)sqrt((double) s);
while(s%n)
n--;
n=*(n+s/n);
printf("%d\n",n);
}
return ;
}
 

HDU 5224 Tom and paper(最小周长)的更多相关文章

  1. hdu 5224 Tom and paper

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5224 Tom and paper Description There is a piece of pa ...

  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. 51nod 最小周长

    1283 最小周长 题目来源: Codility 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 一个矩形的面积为S,已知该矩形的边长都是整数,求所有 ...

  5. hdu 5225 Tom and permutation(回溯)

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

  6. HDU 6311 Cover (无向图最小路径覆盖)

    HDU 6311 Cover (无向图最小路径覆盖) Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...

  7. 51nod 1283 最小周长【注意开根号】

    1283 最小周长 题目来源: Codility 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 一个矩形的面积为S,已知该矩形的边长都是整数,求所有 ...

  8. 51nod 1283 最小周长

    一个矩形的面积为S,已知该矩形的边长都是整数,求所有满足条件的矩形中,周长的最小值.例如:S = 24,那么有{1 24} {2 12} {3 8} {4 6}这4种矩形,其中{4 6}的周长最小,为 ...

  9. Tom and paper

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

随机推荐

  1. Spring入门一

    一 简介 1.Spring为企业应用的开发提供了一个轻量级的解决方案,该解决方案包括:基于依赖注入的核心机制.基于AOP的声明式事务管理.与多种持久层技术 的整合,以及优秀的Web MVC框架等等.可 ...

  2. git如何clone所有的远程分支

    问题: 文/赖忠标 周末在家里改了下代码,新建了个angular版本的分支,然后push到coding.net上面了. 今天,到公司却不知道怎么拉取这个angular分支到公司的电脑上面.如下图(1) ...

  3. PHP学习之[第04讲]PHP5.4 运算符、流程控制

    一.运算符: 1.算数运算符:+.-.*./.%.++.-- 2.字符串运算符: <?php $str="string php100"; echo $str."we ...

  4. 【sql进阶】SQL Server 将某一列的值拼接成字符串

    今天在统计报表的时候有这么一个需求,将一列字符串拼接成一行,然后展示到新的列中. 每一项的服务列表如下: 最终想要的结果是 sql如下: select AuxTypeName + ',' from ( ...

  5. IE6和IE7下绝对定位position:absolute和margin的冲突问题解决

    绝对定位的Position:absoulte的元素,会让相邻的兄弟元素的margin-top失效.而如果去掉了兄弟元素的高度又会正常. <div id="layer1" st ...

  6. 谈谈iOS中粘性动画以及果冻效果的实现

    在最近做个一个自定义PageControl——KYAnimatedPageControl中,我实现了CALayer的形变动画以及CALayer的弹性动画,效果先过目: https://github.c ...

  7. Java基础知识强化之IO流笔记09:File类功能

    详见如下: Android(java)学习笔记87:File类使用

  8. Creating a Background Service ——IntentService

    The IntentService class provides a straightforward structure for running an operation on a single ba ...

  9. 模板-->常系数线性齐次递推(矩阵快速幂)

    如果有相应的OJ题目,欢迎同学们提供相应的链接 相关链接 所有模板的快速链接 Matrix模板 poj_2118_Firepersons,my_ac_code 简单的测试 None 代码模板 /* * ...

  10. 自定义android精美聊天界面

    编写精美聊天界面,那就肯定要有收到的消息和发送的消息. 首先还是编写主界面,修改activity_chat.xml中的代码,如下所示: <?xml version="1.0" ...