Please explain the logic .

Its Alice’s birthday and her friend Bob gets him a birthday cake. Its nice delicious circle shaped cake of radius R. Now they need to cut and eat that cake, so Alice fetches a cutter from her kitchen. It is a rectangular cutter of length A and breadth B that would knock of the part of the cake when the cutter is placed over it.

They decided to take turns to cut and eat their cake. Because it is Alice’s birthday, she starts first. In each turn, they place the cutter over the cake, such that it is fully over the cake (i.e., no part of the cutter is outside the cake, or even over some previously cut region of the cake). You need to determine who will get more to eat, given both of them will use the optimal strategies.

Input and Output

The first line will contain the number of test cases T. Each of the next T lines will contain three space separated numbers R A B.

For each test case, you need to determine who will eat more. Print on a line “ALICE”, “BOB” or “EQUAL” accordingly.

Constraints
1 ≤ T, R, A, B ≤ 1000

Sample Input(Plaintext Link)
2
1 2 2
1 1 1
Sample Output(Plaintext Link)
EQUAL
ALICE

Solution:

If rectangle is a*b and radius of circle is r then :

if(a * a + b * b <= 4rr){

    printf("ALICE\n");

}

else{

    printf("EQUAL\n");

}

Let the largest size of the rectangular cutter that can be placed over the circle have dimensions ‘a’ and ‘b’.

now applying hypoteneuse theorem, u get eqn like

a * a + b * b = (2r) * (2r)

ie, a * a + b * b = 4 * r * r

now u just need to check if your cutter fits onto the cake so put a=A and b=B

and if A * A + B * B > 4 * R * R then no one gets to eat anything ,so print “EQUAL”

else print “ALICE” …this is because she gets to cut the cake first and hence can cut the cake in any orientation she likes, note that this means she is not bothered about whether Bob gets to eat maximal quatity…so she for eg. she might start off by cutting it exactly from the centre of the cake.Being the first one to cut the cake ensures that she has the largest part.

//