Code Jam Fair and Square

This is a solution to the FairAndSquare problem asked in the qualification round of Google Code Jam-2013. Please read the problem statement very carefully as the correctness of solution depends heavily on how you understand and interpret the problem statement.

We present here two solutions to the problem one for the small input and the other for the large input -1. The solution for large input of the problem is kind-of inverted approach from the straightforward one taken for the small input solution. This is also in accordance to the second approach as described in the Code Jam Analysis of the problem.

Solution for Small input:


Solution Large Input – 1

Rate this post

Leave a Reply