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. BZOJ 1257 余数之和sum(分块优化)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=46954 题意:f(n, k)=k mod 1 + k mod 2 ...

  2. HDU2084-数塔

    描述: 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少? 代码: 简单的动态规划 ...

  3. cocos2dx定时器

    cocos2dx三种定时器的使用以及停止schedule,scheduleUpdate,scheduleOnce 首先,什么是定时器呢?或许你有时候会想让某个函数不断的去执行,或许只是执行一次,获取你 ...

  4. mybatis获取插入的语句主键(自增主键)

    <insert id="insertUser" parameterType="User"> <selectKey keyProperty=&q ...

  5. Oracle笔记(十三) 视图、同义词、索引

    一.视图 在之前所学习过的所有的SQL语法之中,查询操作是最麻烦的,如果程序开发人员将大量的精力都浪费在查询的编写上,则肯定影响代码的工作进度,所以 一个好的数据库设计人员,除了根据业务的操作设计出数 ...

  6. IMP-00008: unrecognized statement in the export file: string的问题分析

    分类: Linux 上周需要将oracle10g中的某一个用户下的对象导入到oracle11g中去.用exp在10g的数据库服务器上导出的dump文件,再用imp在11g的数据库服务器上将dump文件 ...

  7. 一,PHP 语法

    基本的 PHP 语法 PHP 的脚本块以 <?php 开始,以 ?> 结束.您可以把 PHP 的脚本块放置在文档中的任何位置. 当然,在支持简写的服务器上,您可以使用 <? 和 ?& ...

  8. 转: Nodejs概述

    目录 简介 安装与更新 版本管理工具nvm 基本用法 REPL环境 异步操作 全局对象和全局变量 模块化结构 概述 核心模块 自定义模块 fs模块 Stream模式 http模块 实例:搭建一个HTT ...

  9. Android PNG渐变背景图片失真问题 getWindow().setFormat(PixelFormat.RGBA_8888);

    最近一个困扰很久的问题,渐变效果的png图片,设置为控件图片或background时,在eclipse上看着没有什么问题,但是在设备上运行时,可以看到明显的一圈圈的轮廓线,图片严重失真.在网上goog ...

  10. ACM_HDU 1231 最大连续子序列 (dp)_代码分析

    Problem Description 给定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ Ni, Ni+1, ..., Nj },其中 1 <= i < ...