'''
int lastRemaining(int n) {
if (1 == n)
{
return 1;
}
int p = lastRemaining(n/2);
return (n/2 - p + 1) * 2;
}
''''
@suozhoutangxin int p = lastRemaining(n/2), p is the last position of input n/2. So (n/2 - p + 1) actually gets the opposite position. And then multiple 2 gets the position of input n.