BITFRENZY

a blog dedicated to technology and programming to shape nation's future.

Breaking

Post Top Ad

Thursday, May 16, 2019

Utopian tree Hackerrank solution in c

#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<math.h>
int main()
{
int n;
scanf("%d",&n);
int h=0;
int t;
for(int i=1;i<=n;i++)
{
scanf("%d\n",&t);
for(int j=0;j<=t;j++)
{
if(j==0)
h=1;
else
if(j%2!=0)
h=h*2;
else
if(j%2==0)
h=h+1;
}
printf("%d\n",h);
}
return 0;
}




No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages