Right triangle
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Time Limit: 2.0 s
Memory Limit: 32.0 MB
Description
A right-angled triangle is a triangle in which one of three angle is 90 degree. Three sides of the triangle are named as height,base and hypotenuse (opposite side of right angle).
You are given the base B of the triangle which is a positive integer. Your task is to find a right-angled triangle of which the base is B and other two sides (height,hypotenuse) are also positive integers. Print the perimeter of the triangle.
If there are many answers print the largest perimeter possible.
Note:
* perimeter is the sum of three sides of a triangle
* integer is a whole number (without fraction). such as 1,2,3,...50,10 are integers and 1.4, 5.99, 3.01 are not.
Input
first line of input takes an integer T: number of testcases
each testcase, takes an integer B: base of the triangle
1 <= \(T\) <= 10
1 <= \(B\) <= 1000
Output
print T lines, each line should consist an integer : perimeter of the triangle
if there is no triangle possible print -1
Sample
Input | Output |
---|---|
|
|
in case 1, it is not possible to make a triangle which has a base 1 and two other sides of positive integer length.
in case 2, base = 3, height = 4 , hypotenuse = 5 so the perimeter is 3+4+5=12. It can be shown that it is not possible to construct any other triangle which has a larger perimeter than 12 with base 3.
Brain booster #2
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 11
- Start at
- 2024-03-06 13:00
- End at
- 2024-03-06 17:00
- Duration
- 4.0 hour(s)
- Host
- Partic.
- 49