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. Android百度地图的简单实现

    2015-06-13 最近学习了百度地图API的简单开发,现记录如下:(持续更新中) 百度地图API是为开发者免费提供的一套基于百度地图服务的应用接口,包括JavaScript API.Web服务AP ...

  2. Android 开发笔记 “The constructor AlertDialog.Builder(new View.OnKeyListener(){}) is undefined”

    1.The constructor AlertDialog.Builder(new View.OnKeyListener(){}) is undefined等,应该有很多类似问题 比如你的源码文件名是 ...

  3. php 不能同时提交form

    注意:提交form到相应的页面时,不能在form中嵌套一个form,否则,不能提交

  4. cocos2dx 随机函数

    cocos2dx 随机数  2.2.3版本 1.初始化时设定随机数种子,只需一次. time_t now = time(NULL); srand((unsigned int)now); 2.需要的时候 ...

  5. 射频识别技术漫谈(18)——Mifare Desfire

    Mifare  DESFire(MF3 IC D40/D41,本文以D40为例)遵守14443 TypeA协议,卡内的数据以文件形式存储,所以有人认为它是准CPU卡,主要用于安全性要求较高的非接触式领 ...

  6. haproxy 超时机制

    <pre name="code" class="python">option redispatch option redispatch 是否允许重新 ...

  7. 技术不牛如何才拿到国内IT巨头的Offer

    不久前,byvoid面阿里星计划的面试结果截图泄漏,引起无数IT屌丝的羡慕敬仰.看看这些牛人,NOI金牌,开源社区名人,三年级开始写Basic...在跪拜之余我们不禁要想,和这些牛人比,作为绝大部分技 ...

  8. VS2010 简单实用快捷键

    VS2010 简单实用快捷键 1). Ctrl+H: 替换 2). Ctrl+F: 查找 3). F5: 启动调试 4). CTRL + F7 生成编译 5). Ctrl+F5: 开始执行(不调试) ...

  9. [置顶] SQL日期类型

    在做机房收费系统的时候,上下机,我觉得是我在整个系统中遇到最棘手的问题了,现在就给大家,分享一下,我是怎样解决的. SQL中有3中数据类型是关于日期的,每一种的用法是不同的,当你用错了,就会出现下面这 ...

  10. Android实现视频录制

    安卓实现视频录制,有两种方法,一种是调用自带的视频功能,一种是使用MediaRecorder. 每种方法都有自己的优缺点.接下来,把两种方法的代码写出来. 先说第一种方法,也是最简单的方法,那就是直接 ...