IITWPC4B - Maggu and Triangles
Maggu has a wire of length n. He has to make triangles out of it such that the side lengths of each triangle are integers. He now wants to know the number of distinct (not congruent) triangles that he can create using the wire of length n. Note that he has to use all of the wire in making the triangle.
First line contains T: number of test cases. (1 <= T <= 10^5)
For each test case, there is a single line containging an integer n (n >= 1 && n <= 10^9)
Each test case output a single integer representing the number of triangles he can create.
faltu question -_-
waste of time
Don't waste your time on this question. This is based on mathematical formula. Just google. You will only benefit if you delve into deriving it else waste of time. Make sure that formula has rounding function and not ceiling or floor.Last edit: 2015-12-23 23:19:05
Shantanu's Comment Really Helped :)
why is it 3 for n=9
for n=5, the only valid triangle which can be formed is of sides 1,2,2. hence ans is 1. ;)
@Ankush Jain ans for n=4 is 0
What is the answer for n = 4? In general, do we have to consider cases where area of formed triangle is 0? (I used a popular theorem available online, and it did not get accepted).