The Utopian tree goes through 2 cycles of growth every year. The first growth cycle occurs during the monsoon, when it doubles in height. The second growth cycle occurs during the summer, when its height increases by 1 meter.
Now, a new Utopian tree sapling is planted at the onset of the monsoon. Its height is 1 meter. Can you find the height of the tree after N growth cycles?java
Input Format
The first line contains an integer, T, the number of test cases.
T lines follow. Each line contains an integer, N, that denotes the number of cycles for that test case.spa
Constraints
1 <= T <= 10
0 <= N <= 60code
Output Format
For each test case, print the height of the Utopian tree after N cycles. orm
Sample Input #00:blog
2 0 1
Sample Output #00:rem
1 2
Explanation #00:
There are 2 test cases. When N = 0, the height of the tree remains unchanged. When N = 1, the tree doubles its height as it's planted just before the onset of monsoon. it
Sample Input: #01:io
2 3 4
Sample Output: #01:class
6 7
Explanation: #01:
There are 2 testcases.
N = 3:
the height of the tree at the end of the 1st cycle = 2
the height of the tree at the end of the 2nd cycle = 3
the height of the tree at the end of the 3rd cycle = 6 test
N = 4:
the height of the tree at the end of the 4th cycle = 7
题目如上,乌托邦树,第一行输入是有几个test case,后面是每个test case中树要长几轮
树若是长奇数轮就是每次在原基础上+1,偶数次轮数就是每次原基础*2,若是没有增加(n=0),那么树的初始高度为0.
因此题解就是简单的进行奇偶判断累加便可。
主要利用这道题复习java中如何使用scanner
代码以下: