LuckyLand Lottery is a problem directly related to Josephus problem!!!
In short:
There are N peoples (N > 0) arranged in a loop (peoples are numbered from 1 to N) so that 1st person comes after Nth person. In each lottery round the 2nd person wins starting from random number P (0 < P <= N), then next round starts from that position where it was ended before (winners will not consider for next rounds). Given the value of N and P. You need to find the person who wins at last.
AC soln:
ans = N - 1's complement of(N) + P - 1
if(ans > N)
ans = ans mod N
I don't know how does it work...
Have you any Explanation to describe this soln?