码迷,mamicode.com
首页 > 其他好文 > 详细

Problem C HDU 5224

时间:2015-08-02 21:35:17      阅读:120      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!