首页 > 其他 > 详细

Problem C HDU 5224

时间:2015-08-02 21:33:18      阅读:184      评论:0      收藏:0      [点我收藏+]

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\leq 10,n\leq {10}^{9}
 

  Output

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

Sample Input

3 2 7 12
 

Sample Output

6 16 14
 
 
 
 
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	int t,s;
	double m;
	scanf("%d",&t);
	while(t--)
	{
		int x,y,c;
		int mini=1e9;
		scanf("%d",&s);
		m=(double)sqrt(s);
		for(x=1;x<=m;x++)
		{
			if(s%x==0)
			{
				y=s/x;
				c=(x+y)*2;
				mini=min(c,mini);
			}
		}
		printf("%d\n",mini);
		
	}
}
 
 
 
 

Problem C HDU 5224

原文:http://www.cnblogs.com/xl1164191281/p/4696723.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!