Algorithm Analysis
A cake is placed on a table if its diagonal is not greater than the diameter of the table . That is, if .
Algorithm Implementation
Read the input data.
scanf("%d %d %d",&r,&w,&l);
Calculate the square of the table's diagonal length.
d = w*w + l*l;
Compare the squares of the table's diagonal and the cake's diameter (for example, to avoid using real number arithmetic). Output the result.
if (d > 4*r*r) printf("NO\n"); else printf("YES\n");
Python Implementation
Read the input data.
r, w, l = map(int, input().split())
Calculate the square of the table's diagonal length.
d = w*w + l*l
Compare the squares of the table's diagonal and the cake's diameter (for example, to avoid using real number arithmetic). Output the result.
if d > 4*r*r: print("NO") else: print("YES")