1822Recursive Survival

1822   Recursive Survival

题目描述

n people numbered 1 to n around a circle, we eliminate every second remaining person until only one survives. Define a function J(n), represents the survivor's original number in the circle. For example, J(2)=1, J(10)=5. Now, please calculate this nested function: J(J(J(..J(n)..)))

输入格式:

There are multiple test cases, each with two positive numbers in one line.

The first number represents the number of the people in original cirlcle, the second one represents the times of the function nested.

All the numbers in input file will be less than 2^63-1.

输出格式:

output the result in one line per test case.

输入样例 复制
2 1
10 1
10 2
输出样例 复制
1
5
3

说明

9
28
通过提交
时空限制2000ms/64mb
题目来源
评测方式在线评测
题目类型基础强化
难        度