sjn wrote:Sorry, what i mean is "ceil"
i made the mistake when i posted the topic
Are you sure that it was your mistake and not that your source uses ceill?
ceill is a valid C99 function and handles long double...
Ciao!!!
Claudio
Moderator: Board moderators
sjn wrote:Sorry, what i mean is "ceil"
i made the mistake when i posted the topic
remaintime=ceil(remainbyte/(transferbyte/5.0));
printf(" Time remaining: %ld seconds\n",long(remaintime));
remaintime=remainbyte/(transferbyte/5.0);
printf(" Time remaining: %ld seconds\n",long(ceil(remaintime)));
Rajib wrote:I can't believe myself . . .![]()
![]()
![]()
I get WA with;remaintime=ceil(remainbyte/(transferbyte/5.0));
printf(" Time remaining: %ld seconds\n",long(remaintime));
I get AC with;remaintime=remainbyte/(transferbyte/5.0);
printf(" Time remaining: %ld seconds\n",long(ceil(remaintime)));
only chainge is ceil in printf function...
/* 18,000 Seconds Remaining */
#include <stdio.h>
int main ()
{
/* FILE *in = freopen ("c.in", "r", stdin); /**/
long b=0, B=0, c=0;
scanf("%i", &b);
while (b!=0)
{
c++;
/* if (c!=1)
printf("\n");
*/
long sec=0, time[5];
printf("Output for data set %d, %d bytes:\n", c, b);
B=0;
while (B<b)
{
scanf("%i", &time[sec%5]);
B += time[sec%5];
sec++;
if (sec%5==0)
{
long suma=0, x=0;
double t=0.0;
while(x++<5)
suma += time[x-1];
t = suma/5.0;
double d=0;
if (t!=0)
{
x = (b-B)/t;
d = (b-B)/t;
if (x!=d)
x++;
}
printf(" Time remaining: ");
if (t==0)
printf("stalled\n");
else
printf("%i seconds\n", x);
}
}
printf("Total time: %i seconds\n", sec);
scanf("%i", &b);
if (b!=0)
printf("\n");
}
return 0;
}

Got AC.
Changed the line
printf(" Time remaining: %.0f seconds\n",ceil(remainingBytes/((float)transferedBytes/5.0)));
to
printf(" Time remaining: %.0f seconds\n",ceil(remainingBytes/((double)transferedBytes*0.2)));
and GOT AC.

#include<stdio.h>
#include<math.h>
int main()
{
long size,time,count,sum,n=1,byte,line=0;
double aver,remainsecond;
while(scanf("%ld",&size)==1&& size){
if(line)printf("\n");
line=1;
printf("Output for data set %ld, %ld bytes:\n",n++,size);
sum=0;time=0;count=0;aver=0;
while(sum!=size){
scanf("%ld",&byte);
sum+=byte;
aver+=byte;
count++;
time++;
if(count==5){
count=0;
if(aver==0)printf(" Time remaining: stalled\n");
else {
remainsecond=(size-sum)/(aver/5.0);
printf(" Time remaining: %.0lf seconds\n",ceil(remainsecond));
}
aver=0;
}
}
printf("Total time: %ld seconds\n",time);
}
return 0;
}

Users browsing this forum: No registered users and 1 guest