Description: N soldiers scattered standing on a playground is divided into a grid, the grid points. The grid points represented by the integer coordinates (x, y). Soldiers along the edge of the grid, down, left, right step, but at the same time on any grid point can only be a soldier. In accordance with the command of the officers, soldiers to neatly fitted to a horizontal queue, i.e. arranged in the (x, y) of (x+1, y), ..., (x+n-1, y). How to choose the values of x and y to the soldiers arranged in a minimum total number of moves. Calculated so that all the soldiers lined up his party needs the least number of moves.
To Search:
File list (Check if you may need any files):
shibingliedui.cpp