PRISMSA - TRIANGULAR PRISM
In a far away nation, all the liquid substance are stored in a can of shape of a triangular prism. According to belief, this will bring security to their children. As they are very resource conservative people, unlike the earth natives, they want to use as less as possible amount of the raw material to be used for producing the can, which directly depends on the surface area of the can. Mr. Buzz Light Year, of Star Command, is provided with the responsiblity to find the minimal suface area required to prodce a can of a given volume.
- Consider the material the can is made of to be infinitely thin.
- The base of the prism is equilateral triangle.
- Some formulas:
- a: triangle side's length.
- h: height of the prism.
- Volume, V = (a2 * sin(60°) * h)/2
- Surface Area, S = a2*sin(60°) + 3*a*h
- If not provided by a library, use the alue of 2*acos(0) for PI(π).
- If your result is within 10-2 of the expected result, your solution will be evaluated as correct.
- If your result is between (1-10-2)*expected and (1+10-2)*expected, it will be evaluated as correct.
Given volume will be an integer between 1 and 100000, inclusive.
Input begins with a integer t, number of test cases. Then follows t lines, each one containing an integer, V, given volume.
For each volume, print the minimum surface area required to produce the can in separate line.
Input: 5 10 5 100 245 5421 Output: 30.3872837089 19.1427891970 141.0452767471 256.3318686611 2020.2796324002
Explanation for test case 1:
Volume = 10, a = 3.41995, h = 1.97451, Minimum Surface Area = 30.3872837089
Spelling of precision as **son cost me 1WA. Try at your own risk because ultimately you'll learn nothing except simple math which you have studied in high school.AC in 2nd Go. 0.00 s.
Take into consideration the precision. Solution was right, but precision was set too low, so it gave WA. Set precision higher and AC.
easy clas 12 level ....after this learned two new thing in c++ ...specially use of built in functions..
very easy only 6 line of codeLast edit: 2015-03-23 21:13:28
Alexandre Henrique Afonso Campos:
I enjoyed very much solving this problem :) I filled one page with math equations. Coding was a detail.
Easy Problem completes my 50..
python nails it... AC in 1st attempt
Nice and easy!
Use double if getting stuck !
Jhoan Es Un Bruto:
very easy, sure tutorial