Moderator: Board moderators
amine.hamdaoui wrote:Why do i get WA. I use exact calculation. I have tested my code for all the tests in this topic, and it match!!!!
- Code: Select all
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j,r,n,*y,a;
double *x;
y = (int *) malloc(sizeof(int )*1000001);
x = (double *) malloc(sizeof(double)*1000001);
x[0] = 1;
y[0] = 0;
for(j=1 ; j<1000001 ; j++)
{
x[j] =x[j-1]/2.0;
if(x[j]<1)
{
x[j] *=10.0;
y[j]=y[j-1]+1;
}
else y[j]=y[j-1];
}
scanf("%d",&r);
for(i=1 ; i<=r ; i++)
{
scanf("%d",&n);
printf("2^-%d = %1.3fE-%d\n",n,x[n],y[n]);
}
return 0;
}

Users browsing this forum: No registered users and 1 guest