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

Re: 362 - IO tricky samples

Postby mustak » Wed Sep 09, 2009 7:34 am

Its a really interesting problem to me,it seems very easy at 1st look.But now i got 10 time WA on that and still i cannot understand where my problem is.
I give my code below,plz try to help me with giving correction or any type of tips for the code.

Code: Select all
Code Removed After Accepted.
Last edited by mustak on Mon Apr 26, 2010 11:02 pm, edited 1 time in total.
mustak
New poster
 
Posts: 8
Joined: Sun Sep 06, 2009 5:11 pm

Re: 362 - IO tricky samples

Postby matthiasbreda » Tue Sep 29, 2009 5:30 am

I got 15 time WA --'
i dont know where is my problem,
My code is below,plz heelpp me

Code: Select all
#include <stdio.h>
#include <math.h>

main()
{
      long le=0,x=0;
      scanf("%i",&le);
      while(le!=0)
      {
           x++;
           long sec=0,sec2=0,cont=0,cont2=0,otra,b;
           double remainSeconds;
           printf("Output for data set %d, %d bytes:\n",x,le);
           while(le>cont){
           scanf("%i",&otra);
           cont=cont+otra;
           cont2=cont2+otra;
           sec++;
           sec2++;
            if (sec2==5)
            {
               int remainbyte=le-cont;
               remainSeconds=remainbyte/(cont2/5.0);
     
       
               if(cont2==0){
               printf("  Time remaining: stalled\n");           
               }else{
                     printf("  Time remaining: %d seconds\n",long((ceil(remainSeconds))));
                     }
               sec2=0;     
               cont2=0;         
            }
                                         
          }
        printf("Total time: %d seconds\n", sec);
        scanf("%i", &le);
         printf("\n");
         
            }   
}
matthiasbreda
New poster
 
Posts: 2
Joined: Tue Sep 29, 2009 5:11 am

Re: 362 - IO tricky samples

Postby Shafaet_du » Fri Jan 14, 2011 2:36 pm

HORRIBLE. DONT WASTE YOUR TIME SOLVING THIS,THERE ARE LOTS OF OTHER PROBLEMS.
after 6 wa i got ac with this:
Code: Select all
double remainSecond = (5*(double)rem)/(double)fsum;
printf("   Time remaining: %d seconds\n",int(ceil(remainSecond)));
Shafaet_du
Experienced poster
 
Posts: 147
Joined: Mon Jun 07, 2010 11:43 am
Location: University Of Dhaka,Bangladesh

Re: 362 - IO tricky samples

Postby plamplam » Tue Aug 30, 2011 4:07 pm

One of the worst problems I've seen here :oops: :oops: I feel like kicking my monitor-.- Thanks a lot for the snippet @Shafaet_DU. Thanks to sijan too. Finally got Accepted. :x
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson
User avatar
plamplam
Experienced poster
 
Posts: 151
Joined: Fri May 06, 2011 11:37 am

Previous

Return to Volume III

Who is online

Users browsing this forum: No registered users and 1 guest