Utopian Tree
Problem Statement
The Utopian Tree goes through 2 cycles of growth every year. The first growth cycle occurs during the spring, when it doubles in height. The second growth cycle occurs during the summer, when its height increases by 1 meter.
Now, a new Utopian Tree sapling is planted at the onset of spring. Its height is 1 meter. Can you find the height of the tree afterN growth cycles?
Now, a new Utopian Tree sapling is planted at the onset of spring. Its height is 1 meter. Can you find the height of the tree after
SOURCE CODE:
#include<stdio.h>
void main()
{
int t,test,total;
scanf("%d",&test);
while(test--){
scanf("%d",&t);
total=1;
int flag=1;
while(t--)
{
if(flag){
if(total==1){
total+=1;
}else{
total*=2;
}
flag--;
}
else{
total+=1;
flag++;
}
}
printf("%d\n",total);
}
}