362 - IO tricky samples

All about problems in Volume III. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Postby CDiMa » Tue Feb 03, 2004 11:10 am

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
CDiMa
Experienced poster
 
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Bug in judge

Postby Rajib » Mon Jun 21, 2004 2:56 pm

I can't believe myself . . . :o :o :o

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...
Rajib
New poster
 
Posts: 28
Joined: Tue Nov 04, 2003 6:45 am
Location: Bangladesh

Re: Bug in judge

Postby CDiMa » Tue Jun 22, 2004 8:55 am

Rajib wrote:I can't believe myself . . . :o :o :o

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...

What is the type of the remaintime variable?

Ciao!!!

Claudio
CDiMa
Experienced poster
 
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Postby CodeMaker » Thu Dec 23, 2004 1:54 am

Hi, I got Acc after 7 WA :evil: and all credit goes towards u sjn. This problem made me sick....
Jalal : AIUB SPARKS
User avatar
CodeMaker
Experienced poster
 
Posts: 183
Joined: Thu Nov 11, 2004 12:35 pm
Location: AIUB, Bangladesh

ACCEPTED, finaly....

Postby dootzky » Tue Apr 19, 2005 12:30 pm

seriously, this is one of the problems that make you hate problem solving...

it's fairly simple, but it has a catch. like SJN said, you must do EXACTLY the following, or you won't get ACC.

remainSecond = remainBytes / (transferedBytes/5.0);
printf("%d seconds\n", ceil(remainSecond));

thx SJN for your insight. :D
but i still don't get it. :P :o :roll:
dootzky
New poster
 
Posts: 36
Joined: Tue Apr 12, 2005 12:20 am
Location: belgrade, serbia (ex yugoslavia)

Postby stcheung » Sat Jan 14, 2006 7:21 am

Yeah I also got AC after doing the following:
float remainSecond = remainBytes / (transferedBytes/5.0);

instead of something like:
float transferrate = (transferedBytes/5.0)
float remainSecond = remainBytes / transferrate;

Other than that, you can just use int and float for all your variables. No tricky input, though I wonder what it uses so much memory for. One additional security measure I took is (int)(ceil(remaining)+0.2) which I don't believe is really needed though based on the thread.
stcheung
Experienced poster
 
Posts: 114
Joined: Mon Nov 18, 2002 6:48 am

Thanks

Postby johnplayers » Mon Apr 03, 2006 12:55 pm

I also got AC after what sjn told us to do. I was frustrated at not having been able to submit it for 3 days.
johnplayers
New poster
 
Posts: 5
Joined: Mon Apr 03, 2006 12:52 pm

i'm relieved...

Postby gvs » Fri May 12, 2006 9:55 pm

Man....
such problems are crap....
though I didn't divide by 5.0....
instead i used rate=0.2*transferredbytes;
and then remaintime=ceil(remainbytes/rate);
then used %.0lf to printf the answer....

but if i used rate=transferredbytes/5.0;
then that ceil problem cropped up.... giving me WA.

another thing is that using '\t' for the 'Time remaining' message, gave me PE, whereas, using 'bbbTime remaining:'' (b=blank) gave me AC....
strange.....
does \t signify different lengths in different platforms ???
maKe wHat yoU waNt...... you'll succeed
gvs
New poster
 
Posts: 6
Joined: Sun Jun 19, 2005 7:39 pm

362 - WA please help me.

Postby alamgir kabir » Mon Nov 26, 2007 3:46 pm

I have got it accepted but very much surprised!!!!!!!!!
Ii's a very much technical and fraction error.
so everyone be careful to handle fraction errors.
I type cast the double into long
Thanks all
Last edited by alamgir kabir on Wed Dec 24, 2008 9:38 pm, edited 1 time in total.
alamgir kabir
New poster
 
Posts: 37
Joined: Wed Oct 03, 2007 10:42 am

I have almost 40 submissions and still WA!!!

Postby ligregni » Mon Dec 24, 2007 10:06 pm

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
C: multum in parvo

"a lot since quite few"

http://acmicpc-live-archive.uva.es/nuev ... user=12539
ligregni
New poster
 
Posts: 11
Joined: Thu Nov 29, 2007 12:41 am
Location: Queretaro, M

Re: 362 - WA many times but works for evry cases in forum...

Postby kbr_iut » Fri Apr 18, 2008 11:24 pm

AC,,,code deleted..
Its too pathetic that,,,when I used ceil(double vale) i got WA
when i used ceil(double value+1e-7)i got WA
when I used (int)(double value+.9999999)i got AC....but why?
so think everyone how much one should b careful calculating floating point numbers!
Last edited by kbr_iut on Fri Sep 19, 2008 10:55 pm, edited 1 time in total.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

Re: 362 - IO tricky samples

Postby fR0D » Fri May 30, 2008 10:57 am

can somebody please point out why am i getting WA?
Code: Select all
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.

i tried all test cases on forum and got expected answer still WA.
Last edited by fR0D on Sat Sep 20, 2008 8:49 am, edited 1 time in total.
fR0D
New poster
 
Posts: 29
Joined: Mon Feb 11, 2008 5:59 am

Re: 362 - IO tricky samples

Postby kbr_iut » Sat Sep 20, 2008 12:39 am

u can use that technic posted immediate before u.
suppose
double d contains ur result. u need to round (to ceil)
just use this
long=tem=(int)(d+.9999999);
print tem;

hope it will help.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

Re: 362 why WA man!!!!!!!!

Postby abid_iut » Sat Nov 22, 2008 8:19 pm

why WA it is giving every output right
here is the code:

Code: Select all
#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;
}

i love to wait... wait for better... and better will come...
http://akanoi.webs.com/
abid_iut
Learning poster
 
Posts: 80
Joined: Wed Jul 16, 2008 7:34 am

Re: 362 - IO tricky samples

Postby kbr_iut » Sun Nov 23, 2008 3:40 am

abid_iut.
check ur pm inbox.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

PreviousNext

Return to Volume III

Who is online

Users browsing this forum: No registered users and 1 guest