Tile Breaker (can any one help me with code in c++?)

Given a rectangular tile of dimensions N*M, you have to divide the tile into three rectangular pieces such that the three pieces can be combined (without breaking any piece) to form the original tile. Let the area of the three pieces be a,b and c. You have to find the minimum value of (max(a,b,c) - min(a,b,c)).
Sample Input 1
3 5

Sample Output 1
0

Explaination : we can break tile into (15) (15) (1*5)

Sample Input 2
4 5

Sample Output 2
2

Explaination : we can break tile into (42) (23) (2*3)

Comments (1)