no tags 

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.


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.


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).


Sample Input:

Sample Output:
Case 1: 4.25

hide comments
Saurav Singhi: 2019-10-12 02:34:29

spoiler alert for java. 1 WA for not remembering java's default typecasting during evaluation of regular expressions.

sanket17: 2019-07-10 10:39:04

if you got the logic then use of double ,float not required

Last edit: 2019-07-10 10:40:43
anon_007: 2019-06-23 09:00:01

use of setprecision is must costed me 4 WAs...

aj_254: 2019-05-23 21:48:52

5 line code in python remember output format cose me one WA. very easy qusetion just need to diffretiate

pandey101299: 2019-02-08 13:52:56

Easy one but use double for sum

cypher33: 2019-01-04 17:17:34

Stupid Output format costed me 2 WA.... That was fair dinkum pain in the butt

prabhav_123: 2019-01-02 22:36:09

\n costed me 1 WA, LOL!

Rahul Kathuria: 2018-11-19 13:20:13


Last edit: 2018-11-19 13:26:03
saket13: 2018-08-29 21:17:39

Be aware of the output format(Case 1: ans)
Costed me two WAs..

akjol2049: 2018-08-23 20:10:10

OMG...just (2*r)^2 and 0.25. Always the case:). As limit of angle between AB and diagonal approaches to 180.

Added by:Muhammad Ridowan
Time limit:0.680s-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)