SOLUTION TO RROOT SPOJ - REAL ROOT SPOJ
RROOT - REAL ROOTS : (link to the question)
x^2 + 2*b*x + c = 0 , for the real roots of this quadratic equation, delta should be >= 0, which is 4*(b^2 - c) here ,
x^2 + 2*b*x + c = 0 , for the real roots of this quadratic equation, delta should be >= 0, which is 4*(b^2 - c) here ,
or b*b - c >= 0 which mean if c <= 0 , no need to bother about b since delta will always be positive.
but when c > 0, then we need to check where delta is non - negative.
follow the steps:
b^2 - c < 0 ( this part we gotta exclude ).
b^2 < c
here by, we can conclude that all we have to do is to exclude the area inclosed by parabola with the upper side of square.
After all the evaluation, we'll get 1 - 1/(3 * sqrt(n/2)) as an answer.
#include<stdio.h> #include<math.h> int main() { int t; double d; scanf("%i",&t); while(t--) { scanf("%lf",&d); printf("%0.6lf\n", 1 - 1/(3*sqrt(d/2))); } return 0; }
No comments:
Post a Comment
Your comment is valuable to us