Page 2 of 4

573 Sample Input Output plz

Posted: Fri Sep 16, 2005 7:00 am
by Tanu
Is there anyone tell what critical in this problem??
Is related with floating point error??
What the the success means?
passed>=height or passed>height
And
Failed means?
passed <= 0 or passed < 0

Sample Input Output plz...

Posted: Wed Oct 12, 2005 1:47 am
by Jan
I think there is no tricky input. You can try the input output set...
Input:

Code: Select all

2 2 2 20
8 6 5 30
97 56 3 10
56 3 1 5
85 26 19 10
59 17 13 11
97 73 23 17
0 0 0 0
Output:

Code: Select all

failure on day 2
failure on day 3
success on day 2
failure on day 32
failure on day 7
failure on day 6
success on day 2
Passed means current height > well height
Failed means current height < 0

Hope it helps.

Hi

Posted: Sun Oct 16, 2005 3:17 pm
by Tanu
Thanx

Posted: Tue Feb 21, 2006 9:02 am
by Darko
I strongly disagree with this advice:
Try considering all input as floating point value.
Note that there is no need for floating point arithmetic at all. Instead of dividing something, multiply the rest.

Darko

Re: 573 The Snail Why WA ?

Posted: Sat Jun 21, 2008 3:20 pm
by Chirag Chheda

Code: Select all

Removed
Thanx to Jan :D

Re: 573 The Snail Why WA ?

Posted: Mon Jun 23, 2008 8:19 am
by Chirag Chheda
Can someone plz reply..
Thanx in advance

Re: 573 The Snail Why WA ?

Posted: Wed Jun 25, 2008 10:19 pm
by Jan
Convert the real numbers to integers (by multiplying a common constant). Then use integer arithmetic only. I have forgot the problem but I think that the precision part is quite critical for this problem.

Re: 573 The Snail Why WA ?

Posted: Tue Jul 13, 2010 2:20 pm
by Kishwar Shafin
Thnx Jane Alam Jan for your Sample..it really helped...but my code got accepted in ANSI C but it returns time limit exceeded in C++ ...i want to know y?

Re: 573 The Snail Why WA ?

Posted: Wed Jul 14, 2010 5:16 pm
by sohel
If you post your code, it'd be easier for us to spot the reason. :)

Re: 573 The Snail Why WA ?

Posted: Fri Nov 05, 2010 5:24 am
by dennywithy
why i get wrong output at this test:
50 5 3 14 ->9 (my output)
50 6 4 1 ->89
50 6 3 1 ->19
1 1 1 1 -> 1
?

Code: Select all

#include <stdio.h>
#include <iostream>

using namespace std;
int main() {
    float h,u,d,f;
    do {
       int hari=0;
        scanf("%f %f %f %f",&h, &u, &d, &f);
        if (h>0) {
            float cur =0;
            float after=0; bool stat = true;
            do {
                hari ++;
                if (cur >= h) stat = false;
                after = u + cur;
                cur = after - d;
                if (cur <0) stat = false;
                if (after >h) stat = false;
                u = u - (u * f/100);
                if (u<=0) stat = false;
                //u>=0 && (cur >=0 && cur < h) && after < h)
                
                } while (stat);
                if (u <=0 || cur <0) printf("failure on day %d\n",hari);
                else if (after >= h) printf("succes on day %d\n",hari);
            }
        } while (h!=0);

}
thx :)

Re: 573 The Snail Why WA ?

Posted: Thu Jul 14, 2011 4:10 pm
by Ahmad
dennywithy wrote:why i get wrong output at this test:
from the problem statement
(The distance lost to fatigue is always 10% of the first day's climbing distance.)

keep this in mind ;)

Re: 573 The Snail Why WA ?

Posted: Thu Jul 14, 2011 4:18 pm
by Ahmad
i have a question guys ... how can i get this 0.000 time ?!

Re: 573 The Snail Why WA ?

Posted: Thu Dec 01, 2011 8:17 am
by rucczh
There is a tricky!
Pay attention to this.
If you keep reducing the value u, u may be negative, which is obviously wrong!!

try this
56 3 1 5
answer is
failure on day 32
not failure on day 28

Re: 573 The Snail Why WA ?

Posted: Sat Dec 21, 2013 5:26 am
by NickStern
Hi I was wondering if someone could help me figure out why my code keeps getting WA. It passes all of the test input and the input described in the board here. Thank you in advance.

Code: Select all

import java.util.*;
class Main {
    public static void main (String args[])
    {
        (new Main()).Snail();
        System.exit(0);
    }
    void Snail()
    {
        Scanner scan = new Scanner(System.in);
        double height, distance, drop, fatigue, length;
        int day;
        height = -1;
        while (height != 0)
        {
            height = scan.nextDouble();
            if (height != 0)
            {
                length = 0;
                day = 0;
                distance = scan.nextDouble();
                drop = scan.nextDouble();
                fatigue = (scan.nextDouble() / 100) * distance;
                if (length < height)
                {
                length += distance - drop;
                day++;
                }
                while (length >= 0 && length <= height)
                {
                    if (distance - fatigue > 0)
                    distance -= fatigue;
                    else
                    distance = 0;
                 length += distance;

                  if (length <= height)
                  {
                   length -= drop;

                  }
                    day++;
                }
                if (length < 0)
                {
                  System.out.println("failure on day " + day);
                }
                else
                {
                    System.out.println("success on day " + day);
                }
            }
        }
    }
}

Re: 573 The Snail Why WA ?

Posted: Sat Dec 21, 2013 10:04 am
by Farsan
Before AC i received a WA because i overlooked the statement "If the fatigue factor drops the snail's climbing distance below zero, the snail does not climb at all that day" .