I am making a program to store all the powers of 2(1,2,4,8...) till 2 ^50000.
Although I am getting the answer,I am not getting my answer in the required time limit.
Any suggestions?
How should I store the numbers?
Here is my stupid code as of now
#include<stdio.h>
#include<math.h>
#include<string.h>
int bin[16604];
int main()
{
int n;
int t,i,j;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(i=0;i<16604;i++)
{
bin[i]=0;
}
bin[16603]=1;
//bin[4]=3;
int temp=0,x=0;
for( j=1;j<=n;j++)
{
for(i=16604;i>=0;i--)
{
temp=bin[i]*2+x;
bin[i]=temp%10;
x=temp/10;
// printf("temp %d x %d bin[i] %d\n",temp,x,bin[i]);
}
temp=0;x=0;
}
int j;
for( j=0;j<16604;j++)
if(bin[j])
break;
for( i=j;i<16604;i++)
{
printf("%d",bin[i]);
} //printf("%d",sum[n]);
putchar('\n');
}
return 0;
}
Here t is my number of test cases....
Here n is the number whose 2^n I am displaying.
Eg
2
10
1024
5
32