Problem A
The End of the World
Legend says that there is a group of monks who are solving a large Towers of Hanoi puzzle. The Towers of Hanoi is a well-known puzzle, consisting of three pegs, with a stack of disks, each a different size. At the start, all of the disks are stacked on one of the pegs, and ordered from largest (on the bottom) to smallest (on the top). The object is to move this stack of disks to another peg, subject to two rules: 1) you can only move one disk at a time, and 2) you cannot move a disk onto a peg if that peg already has a smaller disk on it.
The monks believe that when they finish, the world will end. Suppose you know how far they’ve gotten. Assuming that the monks are pursuing the most efficient solution, how much time does the world have
Input
There will be up to
Output
For each test case, print a single number on its own line
indicating the number of moves remaining until the given Towers
of Hanoi problem is solved. Output no extra spaces, and do not
separate answers with blank lines. All possible inputs yield
answers which will fit in a signed
Sample Input 1 | Sample Output 1 |
---|---|
AAA BBB X |
7 0 |