All Tracks Math Problem

Cake Cutting

Easy, Math


Given a Diameter D of circle and two points A and B are fixed at end of the diameter as shown in the figure. Figure
Sachin drew all distinct possible quadrilaterals with the following properties:
1. One of the diagonals is diameter AB (fixed)
2. Other two points lie on the circumference of the circle on opposite sides of \(AB\).
3. All the sides have positive integral lengths.

Two quadrilaterals are said to be distinct if at least one of their vertices is not on the same point on the circumference of the circle.

Let \(A1, A2, B1, B2\) be the areas formed between the quadrilateral and circle, as shown in the figure.

Your task is to find
1. Number of quadrilaterals L with \(A1+A2 > B1+B2\)
2. Number of quadrilaterals E with \(A1+A2 = B1+B2\)
3. Number of quadrilaterals R with \(A1+A2 < B1+B2\)

Input Format

First line of the input consists of an integer T denoting the number of testcases. Each testcase consists of single integer D, diameter of circle.


  • \(1≤ T ≤ 20\)

  • \(2 ≤ D ≤ 10^6\)

Output Format

For each of the testcases, output three space separated integers \(L, E, R.\)

0 4 0

There are 4 possible quadrilaterals with sides in cyclic order starting from point A:
3 4 3 4
3 4 4 3
4 3 3 4
4 3 4 3

In all the cases A1+A2 and B1+B2 are equal hence answer is 0 4 0.

Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic


Initializing Code Editor...
Your Rating:


View All Notifications