-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtopianTree.java
More file actions
48 lines (35 loc) · 1015 Bytes
/
Copy pathUtopianTree.java
File metadata and controls
48 lines (35 loc) · 1015 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.Scanner;
public class UtopianTree
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int numTests;
numTests = in.nextInt();
if(numTests < 1 || numTests > 10)
throw new RuntimeException("Invalid num tests");
int input[] = new int[numTests];
for(int i = 0; i < numTests; i++)
{
int value = in.nextInt();
if(value > 60 || value < 0)
throw new RuntimeException("Invalid test number");
input[i] = value;
}
int start = 1;
for(int i = 0; i < numTests; i++)
{
for(int j = 0; j < input[i]; j++)
{
if(j % 2 == 0)
{
start *=2;
}
else
start++;
}
System.out.println(start);
start = 1;
}
}
}