HDU 5224 Tom and paper (minimum perimeter)
Time
limit:1000MS
Memory Limit:65536KB
64bit IO Format:%i64d &%i64 U
Description
There is a piece of paper in front of Tom, it length and width are integers. Tom knows the area of this paper, he wants to know the minimum perimeter of this paper.
Input
In the first line, there are an integer T indicates the number of test cases. In the next T-lines, there is only one of the integer-n-Every line, indicates the area of paper.
t<=10,n<= 10^9
Output
For each case, output a integer, indicates the answer.
Sample Input
32712
Sample Output
61614 The problem: the area to calculate the minimum perimeter, mathematical problems, AC code
#include <cstdio>#include<cmath>intMain () {intT,s,n; scanf ("%d",&t); while(t--) {scanf ("%d",&s); N=(int) sqrt (Double) s); while(s%N) n--; N=2* (n+s/N); printf ("%d\n", N); }return 0;}
HDU 5224 Tom and paper (minimum perimeter)