@@ -0,0 +1,1646 @@
+package algorithms.implementation;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * Problem Statement: %0D%0A * The Utopian Tree goes through 2 cycles of growth every year. The first growth%0D%0A * cycle occurs during the spring, when it doubles in height. The second growth%0D%0A * cycle occurs during the summer, when its height increases by 1 meter.%0D%0A * %0D%0A * Now, a new Utopian Tree sapling is planted at the onset of spring. Its height%0D%0A * is 1 meter. Can you find the height of the tree after N growth cycles?%0D%0A * %0D%0A * Input Format: %0D%0A * The first line contains an integer, T, the number of test cases.%0D%0A * T lines follow; each line contains an integer, N, that denotes the number of%0D%0A * cycles for that test case.%0D%0A * %0D%0A * Constraints:%0D%0A * 1 %3C= T %3C= 10%0D%0A * 0 %3C= N %3C= 60%0D%0A * %0D%0A * Output Format: %0D%0A * For each test case, print the height of the Utopian Tree after N cycles. Each%0D%0A * line thus has to contain a single integer, only.%0D%0A * %0D%0A * Sample Input: %0D%0A * 3%0D%0A * 0%0D%0A * 1%0D%0A * 4%0D%0A * %0D%0A * Sample Output: %0D%0A * 1%0D%0A * 2%0D%0A * 7%0D%0A */%0D%0Apublic class UtopianTree %7B%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A        Scanner sc = new Scanner(System.in);%0D%0A        %0D%0A        int numCases = sc.nextInt();%0D%0A        %0D%0A        for (int i = 0; i %3C numCases; i++) %7B%0D%0A            int numCycles = sc.nextInt();%0D%0A            %0D%0A            int height = 1;%0D%0A            for (int cycle = 1; cycle %3C= numCycles; cycle++) %7B%0D%0A                if (cycle %25 2 == 1) %7B%0D%0A                    height *= 2;%0D%0A                %7D else %7B%0D%0A                    height += 1;%0D%0A                %7D%0D%0A            %7D%0D%0A            %0D%0A            System.out.println(height);%0D%0A        %7D%0D%0A        sc.close();%0D%0A    %7D%0D%0A%7D

Add UtopianTree