The Battle Frontier
All submissions for this problem are available.
Ash & Pikachu are ready to face the battle frontier. There are ‘N’ battle facilities, each headed by a frontier brain whom Ash has to face. He can approach the battle facilities for a battle one at a time. Even if he loses at any of the battle facilities he has the option to approach any other facility or compete at the same facility continuously until he wins. Once he has visited a facility, the facility is considered open for him represented by “[” and is closed only after he wins it, represented by “]”. The only restriction is that if he has visited the next facility after losing at a previous one then he has to win the current one in order to compete again in the previous facility. You have to help Ash & Pikachu to find out in how many ways they can approach ‘N’ battle facilities in order to conquer the battle frontier.
The first line contains a single integer T, the number of test cases. T test cases follow. Each testcase consists of a single line consisting of a single number N.
For each test case, output a single line consisting of the number of different ways possible for the respective test case..
- 1 ≤ T ≤100
- 0 ≤ N≤100
Input: 2 2 3 Output: 2 5
For the N=2 , the solutions is 2 because in the following ways:
Ash approaches the first facility, loses their and then moves to the next facility and fights there. Now as he cannot return to the first facility without winning the current one, he wins the second one after a few tries and then returns to the first one and wins there.
Ash approaches the first facility, competes there until he wins and then goes to the next facility and wins there.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, RUBY, PHP, SCALA, PERL, LISP sbcl, LISP clisp, JS, PERL6|
Fetching successful submissions