Friday, December 12, 2014

ACM 1224. Spiral / Спираль

 After examining the task on some samples we can understand the following, if initially we are facing right, then until the next time we will face right is the time when we will be considering a board of Size N-2,M-2 and on this process we did 4 turns. So, the answer would be , generally speaking (N/2)*4. But here is one more thing, when we are down to 1 then we are not making any turns if N gets 1, but if N gets 1 we are making only one more turn , which means that if (N<=M) answer is 2*N-2 otherwise it is 2*M-2+1 which is 2*M-1.


       FULL SOURCE CODE 

No comments:

Post a Comment