-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutopian_tree.java
More file actions
34 lines (28 loc) · 914 Bytes
/
Copy pathutopian_tree.java
File metadata and controls
34 lines (28 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//// https://www.hackerrank.com/challenges/utopian-tree
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner s = new Scanner(System.in);
int t = s.nextInt();
for(int i=0;i<t;i++){
int tree_height = 1;
int cycles = s.nextInt();
int c=0;
for(c=0;c<cycles;c++)
{
if(c%2==0){
tree_height = 2*tree_height;
}
else{
tree_height = tree_height+1;
}
}
System.out.println(tree_height);
}
}
}