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
kaushivam:
2016-08-22 12:04:51
easy ,did'nt write case i: ,cost me 1 WA
|
|
sharath_111:
2016-07-29 20:24:26
my 50th problem on spoj :)
|
|
sssymm:
2016-07-26 20:05:53
Its an elementary problem.
|
|
baadshah_:
2016-06-23 12:57:07
Only Need school level Mathametics to solve this problem(Circle)
|
|
Anirban Acharya:
2016-06-21 18:56:44
For people thinking differentiation is needed to maximize the function, well its not so. In fact, its much simpler than that. |
|
hassanarif63:
2016-06-19 09:55:22
#Fun With Mathematics |
|
sonali9696:
2016-06-07 17:43:19
About all the confusion regarding double and int. See upto 10^4,it's okay but after this to get accurate results you need datatype with longer range like double or long long int. Don't worry there is no fractional radius input.AC in one go Last edit: 2016-06-07 17:43:57 |
|
pranjalikumar9:
2016-06-05 22:22:59
Take radius as double and check for r=1000000 also print precision upto 2 places..wont harm you..
|
|
rohittt:
2016-05-03 19:58:51
wrong constraints..stupid ques..cost me 1 WA...!!
|
|
Pradd:
2016-04-16 15:16:16
4 lines in Python. It's more of a maths problem then programming. If you don't know differentiation, then go learn it and it's applications. It's useful for maximum and minimum calculations. |
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) |