573 The Snail Why WA ?

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

Moderator: Board moderators

573 Sample Input Output plz

Postby Tanu » Fri Sep 16, 2005 7:00 am

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...
User avatar
Tanu
Learning poster
 
Posts: 70
Joined: Sun May 29, 2005 12:46 pm
Location: Mars

Postby Jan » Wed Oct 12, 2005 1:47 am

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.
Ami ekhono shopno dekhi...
HomePage
Jan
Guru
 
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh

Hi

Postby Tanu » Sun Oct 16, 2005 3:17 pm

Thanx
User avatar
Tanu
Learning poster
 
Posts: 70
Joined: Sun May 29, 2005 12:46 pm
Location: Mars

Postby Darko » Tue Feb 21, 2006 9:02 am

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
Location: Calgary, Canada

Re: 573 The Snail Why WA ?

Postby Chirag Chheda » Sat Jun 21, 2008 3:20 pm

Code: Select all
Removed


Thanx to Jan :D
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 ?

Postby Chirag Chheda » Mon Jun 23, 2008 8:19 am

Can someone plz reply..
Thanx in advance
Chirag Chheda
Learning poster
 
Posts: 74
Joined: Sat Jun 21, 2008 12:24 pm
Location: India

Re: 573 The Snail Why WA ?

Postby Jan » Wed Jun 25, 2008 10:19 pm

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
Location: Dhaka, Bangladesh

Re: 573 The Snail Why WA ?

Postby Kishwar Shafin » Tue Jul 13, 2010 2:20 pm

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 ?

Postby sohel » Wed Jul 14, 2010 5:16 pm

If you post your code, it'd be easier for us to spot the reason. :)
User avatar
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 ?

Postby dennywithy » Fri Nov 05, 2010 5:24 am

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 ?

Postby Ahmad » Thu Jul 14, 2011 4:10 pm

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 ;)
Ahmad
New poster
 
Posts: 16
Joined: Thu Apr 28, 2011 10:48 pm

Re: 573 The Snail Why WA ?

Postby Ahmad » Thu Jul 14, 2011 4:18 pm

i have a question guys ... how can i get this 0.000 time ?!
Ahmad
New poster
 
Posts: 16
Joined: Thu Apr 28, 2011 10:48 pm

Re: 573 The Snail Why WA ?

Postby rucczh » Thu Dec 01, 2011 8:17 am

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
rucczh
New poster
 
Posts: 1
Joined: Thu Dec 01, 2011 8:09 am

Previous

Return to Volume V

Who is online

Users browsing this forum: No registered users and 1 guest