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. svn server安装配置

    安装平台:RHEL5 1.安装软件:httpd.subversion.mod_dav_svn 2.修改配置 修改/etc/httpd/conf.d/subversion.conf.eg: LoadMo ...

  2. 尚学堂 JAVA Day13 abstract 关键字

    Abstract (抽象的) 这是一个关键字. 可以且只可以 用来修饰 <类> <方法>. 1---Abstract 类 如:Animal,可以被理解一个抽象的类.动物嘛,只是 ...

  3. How many - HDU 2609 (trie+最小表示)

    题目大意:有 N 个手链,每个手链的最大长度不超过100,求出来最多有多少个不同的手链.   分析:因为手链是可以转动的,所以只要两个手链通过转动达到相同,那么也被认为是一种手链,然而如果每次都循环比 ...

  4. 333. Largest BST Subtree

    nlgn就不说了..说n的方法. 这个题做了好久. 一开始想到的是post-order traversal. 左右都是BST,然后自己也是BST,返还长度是左+右+自己(1). 左右其中一个不是,或者 ...

  5. 字符串的encode与decode解决乱码问题

    !/usr/bin/env python coding=utf-8 s="中文" if isinstance(s, unicode): s=u"中文" prin ...

  6. spring注入成员对象

    就是将对象注入到另外一个对象中.这个样例就是有一个学校类,学校类中有一个校长类,最后使用測试文件输出学校类中的信息. 代码结构 学校类 package com.test.SpringGetSet; p ...

  7. Fedora14下首次搭建Samba服务器遇到的一些问题

    SMB(Server Messages Block,信息服务块)是一种在局域网上共享文件和打印机的通信协议.而Samba则是在Linux和Unix系统上实现SMB协议的一个免费软件,由服务器及客户端程 ...

  8. POJ 3449 Geometric Shapes (求正方形的另外两点)

    Geometric Shapes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 1470   Accepted: 622 D ...

  9. python面对对象编程----------7:callable(类调用)与context(上下文)

    一:callables callables使类实例能够像函数一样被调用 如果类需要一个函数型接口这时用callable,最好继承自abc.Callable,这样有些检查机制并且一看就知道此类的目的是c ...

  10. JAVA中的finalize()方法

    [转]JAVA中的finalize()方法 今天早上看Thinking in java的[第四章 初始化和清除].[  清除:终结和垃圾回收]的时候, 看到了这个东西. 用于清理滴... 当然,这个方 ...