MAXLN - THE MAX LINES
In this problem you will be given a half-circle. The half-circle’s radius is r. You can take any point A on the half-circle and draw 2 lines from the point to the two sides of the diameter(AB and AC). Let the sum of square of one line’s length and the other line’s length is s
Like in the figure s = AB2 + AC. And BC = 2r.
Now given r you have to find the maximum value of s. That is you have to find point A such that AB2 + AC is maximum.
Input
First line of the test case will be the number of test case T (1 ≤ T ≤ 1000). Then T lines follows. On each line you will find a integer number r (1 ≤ r ≤ 1000000); each representing the radius of the half-circle.
Output
For each input line, print a line containing "Case I: ", where I is the test case number and the maximum value of s. Print 2 digit after decimal (Errors should be less then .01).Example
Sample Input: 1 1 Sample Output: Case 1: 4.25
hide comments
ISHPREET:
2016-02-26 03:52:07
Shortest code ever use int only :) |
|
pt97:
2016-01-10 17:45:56
use int and double respectively will cause AC in first
|
|
amanjain5221:
2016-01-08 20:19:58
i used int for radius and long double for ans and i used correctly the precision ....... not worked
|
|
sarthak_8:
2015-12-28 18:37:27
For the people doing it in C++ just using float or double won't help because it gives the output in scientific notation. Set the precision manually and then give it a try. Got 3 WA because of the double's output format. Otherwise the question is easy. Finally AC :) |
|
pvsmpraveen:
2015-12-26 15:59:18
Once you derived the equation using basic calculus and geometry,
|
|
archit saxena:
2015-12-22 18:29:34
long long int for radius
|
|
sadiq18:
2015-11-13 04:38:12
take radius in double not long int
|
|
vishals:
2015-10-19 10:25:55
basic trigonometry and quadratic eqn. .. very easy problem
|
|
sampawan:
2015-08-25 13:15:32
easy one :)
|
|
sy_117:
2015-08-11 21:20:52
take radius in double ........a 12 lines code in C. Accepted in first go.. |
Added by: | Muhammad Ridowan |
Date: | 2011-03-28 |
Time limit: | 1s-1.679s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own Problem(used for CSE,University of Dhaka, Newbies Contest) |