573 - The Snail
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...
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...
I think there is no tricky input. You can try the input output set...
Input:
Output:
Passed means current height > well height
Failed means current height < 0
Hope it helps.
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
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
Failed means current height < 0
Hope it helps.
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- Learning poster
- Posts: 74
- Joined: Sat Jun 21, 2008 12:24 pm
- Location: India
Re: 573 The Snail Why WA ?
Code: Select all
Removed
![:D](./images/smilies/icon_biggrin.gif)
Last edited by Chirag Chheda on Fri Jun 27, 2008 8:08 am, edited 1 time in total.
-
- Learning poster
- Posts: 74
- Joined: Sat Jun 21, 2008 12:24 pm
- Location: India
Re: 573 The Snail Why WA ?
Can someone plz reply..
Thanx in advance
Thanx in advance
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
HomePage
-
- New poster
- Posts: 1
- Joined: Tue Jul 13, 2010 2:16 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?
Re: 573 The Snail Why WA ?
If you post your code, it'd be easier for us to spot the reason. ![:)](./images/smilies/icon_smile.gif)
![:)](./images/smilies/icon_smile.gif)
-
- New poster
- Posts: 1
- Joined: Thu Oct 21, 2010 6:16 pm
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
?
thx ![:)](./images/smilies/icon_smile.gif)
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);
}
![:)](./images/smilies/icon_smile.gif)
Re: 573 The Snail Why WA ?
from the problem statementdennywithy wrote:why i get wrong output at this test:
(The distance lost to fatigue is always 10% of the first day's climbing distance.)
keep this in mind
![;)](./images/smilies/icon_wink.gif)
Re: 573 The Snail Why WA ?
i have a question guys ... how can i get this 0.000 time ?!
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
answer is
failure on day 32
not failure on day 28
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 ?
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 ?
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" .