Nautical Cup 2012 simulation question (C language)