Problem 1666 Simple Hanoi
Accept: 101 Submit: 165
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
The Tower of Hanoi or Towers of Hanoi (also known as The Towers of Brahma) is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks neatly stacked in order of size on one rod, the smallest at the top, thus making a conical shape.
The objective of the puzzle is to move the entire stack to another rod, obeying the following rules:

Only one disk may be moved at a time.

Each move consists of taking the upper disk from one of the pegs and sliding it onto another rod, on top of the other disks that may already be present on that rod.

No disk may be placed on top of a smaller disk.
As we all known, if there are N different disks, the minimum movements from the initial state (the N disks neatly stacked in order of size on one rod) to the finish state (the N disks neatly stacked in order of size on the other rod) are 2^N1. Give you the number of disks and the label of the disk; please calculate the minimum movements of the labeled disk in the problem.
Input
There are multiply test cases. For each test case, the first line are two integer N and K(1≤N≤60, 1≤K≤N), indicating the number of disks and the special labeled disk. The N disks are labeled from 1 to N; the smaller labeled disk has the smaller size.
Output
For each test case, output the minimum movements of disk labeled as K when we finish moving.
Sample Input
4 1
60 1
Sample Output
8
576460752303423488
Source
FOJ月赛2008年11月