글
[LuckyAlgorithm]Utopian Tree(24/77)
Algorithm
2018. 1. 4. 08:45
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static int utopianTree(int n) {
int height = 0;
for(int i=0;i<n+1;i++) {
if(i%2 == 0) {
height += 1;
}else {
height *= 2;
}
}
return height;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int a0 = 0; a0 < t; a0++){
int n = in.nextInt();
int result = utopianTree(n);
System.out.println(result);
}
in.close();
}
}
'Algorithm' 카테고리의 다른 글
[LuckyAlgorithm]Permuting Two Arrays(26/77) (0) | 2018.01.18 |
---|---|
[LuckyAlgorithm]The Great XOR(25/77) (0) | 2018.01.09 |
[LuckyAlgorithm]maximizing-xor(23/77) (0) | 2018.01.03 |
[LuckyAlgorithm]Day 26: Nested Logic(22/77) (0) | 2017.12.16 |
[LuckyAlgorithm]Intro to Tutorial Challenges (21/77) (0) | 2017.12.14 |