## 573 The Snail Why WA ?

Moderator: Board moderators

### 573 Sample Input Output plz

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

Tanu
Learning poster

Posts: 70
Joined: Sun May 29, 2005 12:46 pm
Location: Mars

I think there is no tricky input. You can try the input output set...
Input:
Code: Select all
`2 2 2 208 6 5 3097 56 3 1056 3 1 585 26 19 1059 17 13 1197 73 23 170 0 0 0`

Output:
Code: Select all
`failure on day 2failure on day 3success on day 2failure on day 32failure on day 7failure on day 6success on day 2`

Passed means current height > well height
Failed means current height < 0

Hope it helps.
Ami ekhono shopno dekhi...
HomePage
Jan
Guru

Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm

### Hi

Thanx

Tanu
Learning poster

Posts: 70
Joined: Sun May 29, 2005 12:46 pm
Location: Mars

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
Darko
Guru

Posts: 572
Joined: Fri Nov 11, 2005 9:34 am

### Re: 573 The Snail Why WA ?

Code: Select all
`Removed`

Thanx to Jan
Last edited by Chirag Chheda on Fri Jun 27, 2008 8:08 am, edited 1 time in total.
Chirag Chheda
Learning poster

Posts: 74
Joined: Sat Jun 21, 2008 12:24 pm
Location: India

### Re: 573 The Snail Why WA ?

Chirag Chheda
Learning poster

Posts: 74
Joined: Sat Jun 21, 2008 12:24 pm
Location: India

### Re: 573 The Snail Why WA ?

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.
Ami ekhono shopno dekhi...
HomePage
Jan
Guru

Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm

### Re: 573 The Snail Why WA ?

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?
Kishwar Shafin
New poster

Posts: 1
Joined: Tue Jul 13, 2010 2:16 pm

### Re: 573 The Snail Why WA ?

If you post your code, it'd be easier for us to spot the reason.

sohel
Guru

Posts: 862
Joined: Thu Jan 30, 2003 5:50 am
Location: University of Texas at San Antonio

### Re: 573 The Snail Why WA ?

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
dennywithy
New poster

Posts: 1
Joined: Thu Oct 21, 2010 6:16 pm

### Re: 573 The Snail Why WA ?

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
New poster

Posts: 16
Joined: Thu Apr 28, 2011 10:48 pm

### Re: 573 The Snail Why WA ?

i have a question guys ... how can i get this 0.000 time ?!
New poster

Posts: 16
Joined: Thu Apr 28, 2011 10:48 pm

### Re: 573 The Snail Why WA ?

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
failure on day 32
not failure on day 28
rucczh
New poster

Posts: 1
Joined: Thu Dec 01, 2011 8:09 am

Previous