Monday, January 26, 2015

HRK : U tree


import java.util.Scanner;


public class Utopian_tree {

public static void main(String[] args) {
// TODO Auto-generated method stub

Scanner in = new Scanner(System.in);

int[] arrlist = new int[60];
int temp,n = 0;
int test_count;
// int cycle_count;
int height ;


test_count = in.nextInt();
if((test_count>=1 && test_count<=10))
{
for(int c=0;c<test_count;c++)
{
temp = in.nextInt();
if( temp >=0 && temp<=60)
arrlist[n++] = temp;
}

for(int j=0;j<n;j++)
{
height = 1;
for(int i =0 ;i<arrlist[j];i++)
{
if((i%2) == 0 )
{
height = 2*height;
}
else
{
height = height+1;
}
}
System.out.println("" + height);
}
}
}
}

No comments:

Post a Comment