Thursday, August 21, 2014

Snape and Ladder


Problem Link : http://www.codechef.com/problems/SNAPE/

Idea : If B is the base , L is the left side and R is the right side of a triangle ;
Given B and L . You have to calculate the minimum and maximum value for R .
The value of R will be minimum , if the angle between  B and R is 90 degree .
Then it is a right angle triangle and we can easily calculate the value of R by pythagoras theorem .

 So  ,  R min = sqrt(L*L-B*B)

The value of R will be maximum , if the angle between  B and L is 90 degree .
Then it is a right angle triangle and we can easily calculate the value of R by pythagoras theorem .

 So  ,  R max = sqrt(L*L+B*B)

My Solution



No comments:

Post a Comment