Friday 6 February 2015

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 i, t, j, k, x=1, y=1;

t = s.nextInt();
int m[] = new int[t];
for (i = 0; i < t; i++)
{
m[i] = s.nextInt();
}
for (k = 0; k < t; k++)
{
y=1;
for(i=1;i<=m[k];i++)
{
if(i%2==0)
y+=1;
else
y*=2;
}
System.out.println(y);
}
    }
}

No comments:

Post a Comment