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.            
      
                

Output

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

Sample Input

3
2
7
12
                

Sample Output

6
16
14
 
题目大意:
已知面积,求最小周长。
 
分析:
要想求最小周长要已知一条边。C=2*(a/i+i)或C=2*(1+n)将两个进行比较,输出最小值。
注意:
判断i的范围,想到正方形边长=sqrt(n)
 
代码:
 #include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
int a,c;
for(int i=;i<=sqrt(n);i++)
{
a=*(n+); if(n%i==)
c=*(n/i+i);
if(c<=a)
a=c;
}
printf("%d\n",a);
}
return ;
}

c.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(最小周长)

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

  3. hdu 5224 Tom and paper 水题

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

  4. Tom and paper

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

  5. 数据挖掘方面重要会议的最佳paper集合

    数据挖掘方面重要会议的最佳paper集合,兴许将陆续分析一下内容: 主要有KDD.SIGMOD.VLDB.ICML.SIGIR KDD (Data Mining) 2013 Simple and De ...

  6. Summary on Visual Tracking: Paper List, Benchmarks and Top Groups

    Summary on Visual Tracking: Paper List, Benchmarks and Top Groups 2018-07-26 10:32:15 This blog is c ...

  7. CVPR2016 Paper list

    CVPR2016 Paper list ORAL SESSIONImage Captioning and Question Answering Monday, June 27th, 9:00AM - ...

  8. CVPR 2017 Paper list

    CVPR2017 paper list Machine Learning 1 Spotlight 1-1A Exclusivity-Consistency Regularized Multi-View ...

  9. 激光打印机的Color/paper, Xerography介绍

    Color Basic 看见色彩三要素: 光源,物体,视觉 加色色彩模型:R,G,B 多用于显示器 减色色彩模型:C,M,Y,K 多用于打印复印 Paper 东亚地区常用A系列标准用纸,在多功能一体机 ...

随机推荐

  1. 我用过的Linux命令--虚拟机和宿主机的网络连接方式

    VMWare提供了三种工作模式,它们是bridged(bridged模式:对应网卡vment0).NAT(网络地址转换模式:对应网卡vment8)和host-only(主机模式:对应网卡vment1) ...

  2. Lucence.net索引技术 一

    1.建立索引 为了对文档进行索引,Lucene 提供了五个基础的类,他们分别是 Document, Field, IndexWriter, Analyzer, Directory.下面我们分别介绍一下 ...

  3. c#操作MySQL数据库中文出现乱码(很多问号)的解决方法

    前题:修改discuz论坛帖子老连接(从NT版转到PHP版的discuzX3),帖子里有很多引用,有链接都是.aspx这样的链接. 需要将这些链接改到当前论坛的链接. 思路:用asp.net程序获取含 ...

  4. Eclipse4.3正式版已发布

    Eclipse4.3正式版已发布,传送门http://www.eclipse.org/downloads/

  5. java 无法割符日期字符串转yyyy-MM-dd hh:mm:ss

    1.需要转换字符串(20150210125942),转化后要达到的目的:2015-02-10 12:59:42 public static void main(String[] args) { Str ...

  6. JDK JRE先保存 后面再整理

    1. 定义 JRE(Java Runtime Enviroment)是Java的运行环境.面向Java程序的使用者,而不是开发者.如果你仅下载并安装了JRE,那么你的系统只能运行Java程 序.JRE ...

  7. 数据结构- 串的模式匹配算法:BF和 KMP算法

      数据结构- 串的模式匹配算法:BF和 KMP算法  Brute-Force算法的思想 1.BF(Brute-Force)算法 Brute-Force算法的基本思想是: 1) 从目标串s 的第一个字 ...

  8. ZYB's Game(博弈)

    ZYB's Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  9. Android 建造者(Builder)模式

    关于 Builder 模式 详述:http://blog.csdn.net/jjwwmlp456/article/details/39890699 先来张图 看到 Android  中 使用了 Bui ...

  10. JDBC初步(一)

    import java.sql.*; public class TestJDBC { // orcl为oracle数据库中的数据库名,localhost表示连接本机的oracle数据库 // 1521 ...