Hi, I'm desesperate, I need help!,
I have revewed all the output sentences, I tried all the cases I've found and they are OK!,
I also tried printing after each case (including last one) "\n\n", or printing after each case (including last) "\n", but printing after each case (except the last) "\n" (all of this is printing two \n after all cases exept the last, where I only print one) or printing "\n\n" after all cases except last one (who is "empty" after him),
I tried printing all of this combinations after scanning the # of bytes or before that (I need your help giving me the answer of the \n issue, it will help a lot),
I am almost sure the Math issue is correct (for avoid ceil(), I made the same calculus whith a double and an integer, if they are not the same, I print the integer (long actually) plus 1),
I remember you I've tried with all cases I've found and some extrem I thinked (for example, 10000 bytes, and in the first 5 seconds just one byte has been transferred, and after that one stalled, and then all the bytes less one tranfers, and calculus the time remaining),
I also checked all the ':' and that stuff,
I'm getting crazy with this problem,
I know it's OK, but UVa doesn't think the same, and I'm pretty sure it is by any little thing, but I don't know, what, so, here is my code:
Code: Select all
/* 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;
}
This version of my code is the one who prints \n after all cases and another \n after all cases except last one.
I get WA at 0.190 secs aprox, so I know it could be almost at the end.
aprox 5 of my WA was because I forgot to comment the FILE *in line, but I have trained myself to avoid that.
THANKS
Sergio Ligregni