After the second
round of programming contests, Olympiad participants decided to celebrate this
event. For this purpose, a large rectangular cake was ordered. The participants
gathered at the round table. Naturally, they have a question:
is it possible to put a rectangular cake on the round table so that no piece of
cake will extend beyond the table. You need to know the size of the cake and
the radius of the table.
Input. Contains three
positive integers: the radius of the table r (1 ≤ r ≤ 1000), the width of the cake w, and the length of
the cake l (1 ≤ w ≤ l ≤ 1000).
Output. Print the
word “YES”, if the cake can be placed on the table, and the word “NO” otherwise.
Sample input 1 |
Sample output 1 |
38 40 60 |
YES |
|
|
Sample input 2 |
Sample output 2 |
35 20 70 |
NO |
conditional
statement
The cake is placed on the table if
its diagonal is not greater than
the diameter of the table 2r. That is, if w2 + l2
≤ 4r2.
Algorithm
realization
Read
the input data.
scanf("%d %d %d",&r,&w,&l);
Find the square of the length of the diagonal of the table.
d = w*w + l*l;
Compare
the squares of the diagonal of the table and the diameter of the cake (for
example, not to use real number arithmetic). Print the result.
if (d > 4*r*r) printf("NO\n");
else printf("YES\n");
Read
the input data.
r, w, l = map(int, input().split())
Find the square of the length of the diagonal of the table.
d = w*w + l*l
Compare
the squares of the diagonal of the table and the diameter of the cake (for
example, not to use real number arithmetic). Print the result.
if d > 4*r*r:
print("NO")
else:
print("YES")