eolymp
bolt
Try our new interface for solving problems
Problems

Counting Quadrilaterals

Counting Quadrilaterals

In the \textbf{10}x\textbf{10} grid below you can see five different lattice quadrilaterals. (A lattice quadrilateral is a quadrilateral whose vertices have integer coordinates. A quadrilateral is a polygon with four sides and is not self intersecting. None of the internal angles of a Quadrilateral can be equal to \textbf{180} degree) Of course these are only a few lattice quadrilaterals of the millions that can be drawn in this \textbf{10}x\textbf{10} grid. Given an (\textbf{N}x\textbf{N}) grid your job is to count the number of different lattice quadrilaterals in that grid. \includegraphics{https://static.e-olymp.com/content/97/972cfacba32613b8c829eb42450100ba30c055be.jpg} \InputFile The input file contains at most \textbf{150} sets of inputs. Each line contains an integer \textbf{N} (\textbf{0} < \textbf{N} < \textbf{121}). Input is terminated by a line where the value of \textbf{N} is zero. \OutputFile For each line of input produce one line of output. This line contains two integers. First integer is the input number \textbf{N} and the second integer denotes the number of quadrilaterals in an (\textbf{N}x\textbf{N}) grid. It is guaranteed that the second integer will fit in a \textbf{64}-bit signed integer. \textit{\textbf{Warning:}} This problem has no alternate solution so can have mistakes. Actually a brute force solution is written to verify the answers. But that could only verify answers up to (\textbf{22}x\textbf{22}) grid after running for \textbf{14} hours. \textit{\textbf{Tips:}} The time limit of this problem is \textbf{2} seconds and has only specific amount of judge input. So pre-calculation can be a better option if a very efficient solution is hard to find. But of course the most obvious brute force method can take around \textbf{200} years to complete in a \textit{\textbf{1.8 Ghz Pentium IV}} machine.
Time limit 2 seconds
Memory limit 64 MiB
Input example #1
1
2
10
0
Output example #1
1 1
2 94
10 12046294