## 10215 - The Largest/Smallest Box ...

Moderator: Board moderators

nukeu666
New poster
Posts: 44
Joined: Sun Feb 13, 2005 1:13 am
Location: India
Contact:
bleh...finally got it accepted
the program works only with double
float gives the 3rd decimal place rounding off error
does this tell us double is more accurate than float? (even when talking about the 3rd decimal point?)

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Contact:
nukeu666 wrote:does this tell us double is more accurate than float? (even when talking about the 3rd decimal point?)
That is how it is. Nowhere I've used float but double.

ayon
Experienced poster
Posts: 161
Joined: Tue Oct 25, 2005 8:38 pm
i still cannot understand the problem. from observation V=(W-2x)(L-2x)x. for V(max), x has only one value, it has no trouble. but for V(min), x = 0, W/2, L/2; so to determine V(min), i printed 3 values of x, while W != L, and 2 values of x, while W = L, and i got WA. then i checked the board and found that, the program is accepted only for 2 values of x; x = 0 and x = min(W,L)/2. but why not x = 0, min(W,L)/2 and max(W,L)/2, while W != L ?
ishtiak zaman
----------------
the world is nothing but a good program, and we are all some instances of the program

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Contact:
Instead of telling min() or max(), let's consider L>W. Other than 0, W/2 is one answer, you understand. But if you cut L/2 along L axis do you get enough length along W axis to cut the same amount?

ayon
Experienced poster
Posts: 161
Joined: Tue Oct 25, 2005 8:38 pm
i understand, thanks mamun. actually i was treating the problem only with the equation, not with its original visual body.
ishtiak zaman
----------------
the world is nothing but a good program, and we are all some instances of the program

DIR EN GREY
New poster
Posts: 12
Joined: Thu Nov 09, 2006 11:49 am

### Rejudge

Rejudgement makes this problem very very difficult one. Now, accept rate is only 2.0%, of cource I got WA too

http://acm.uva.es/p/problemstat.php?p=:10215

I checked the board, however, judges have just delete some tricky inputs.

http://online-judge.uva.es/board/viewtopic.php?t=12778

Why everybody got wa? I think if judges only delete inputs, programs which got accept first time should be accepted. So there must be some brandnew inputs.

Help! I need somebody, not just anybody but have got accept this time.

Here is my code.

Code: Select all

``````cut after got ac
``````
Last edited by DIR EN GREY on Tue Nov 28, 2006 12:15 am, edited 1 time in total.
Do you understand my English???

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
Add eps before printing anything. I used 1e-7. Hope it helps.
Ami ekhono shopno dekhi...
HomePage

DIR EN GREY
New poster
Posts: 12
Joined: Thu Nov 09, 2006 11:49 am
Jan wrote:Add eps before printing anything. I used 1e-7. Hope it helps.
Thanks Jan!! I got accept immediately, but I can't understand that why I must use eps before printing? How eps works? I always use cout, setiosflags() and setprecision() when round off is required, and they works fine without EPS...

What input is crtical?? When I should use EPS??

Do you understand my English???

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
Imagine that the output is 1.05, but due to floating point calculation, your output became 1.049999999999. Now if you print only one digit after the decimal point your output is 1.0 but the real output is actually 1.1.
Thats why almost all problems that have floating point output are judged with a special judge program (marked by a yellow flag). But some problems dont have the special judge, for those problems its better to add eps before printing any floating point number. And eps should be as small as possible. Using 1e-7 to 1e-11 is sufficient.

Code: Select all

``````double a;
a=0.15;
printf("%.1lf\n",a);``````
The output will show .1, which is obviously not correct. But if you add eps before printing 'a', you will see .2, which is the correct output.
Ami ekhono shopno dekhi...
HomePage

DIR EN GREY
New poster
Posts: 12
Joined: Thu Nov 09, 2006 11:49 am
Thanks Jan!! I understand this issue now. I didn't know purpose of the yellow mark.

Allow me to again thank you
Do you understand my English???

fpavetic
Learning poster
Posts: 51
Joined: Sat Mar 04, 2006 8:00 pm
i got this problem accepted by storing intermediate calculations in long double, and printing the result as double after many failed submissions.

abhiramn
New poster
Posts: 29
Joined: Sat May 26, 2007 7:54 pm

Code: Select all

``````CODE ACCEPTED!!!
``````
Please tell me why this if giving WA
@Mr. Jan
max+=0.0000001 is that what you meant when you said add eps??? If not, please tell me what you meant. Thanks a lot.[[/b]

WingletE
New poster
Posts: 35
Joined: Sun Aug 13, 2006 1:34 pm
Location: Taipei, Taiwan
Contact:

I got a lot of WA and finally got AC at once after changing COUT to printf...

willima
New poster
Posts: 13
Joined: Wed Dec 07, 2005 1:19 pm
Location: Brazil

### Confused

I really didn't undertand why your code print 3 numbers as output for some inputs. My WA code printed the following for the last 3 cases of the first post:

Code: Select all

``````1666.500 0.000 4999.500
0.250 0.000 0.500 4999.500
0.250 0.000 0.500 4999.500
``````
If the minimum volume is 0 and the volume is (L-2x)(M-2x)x, I got:
- L - 2x = 0;
- M - 2x = 0;
- x = 0.

Where is my mistake?

Thanks,

Willian.
"Don't let the day go by
Don't let it end
Don't let the day go by, in doubts
The anwser lis within"

fR0D
New poster
Posts: 29
Joined: Mon Feb 11, 2008 5:59 am
Contact:

### why is my programm giving WA

here's my code....it seems right but gives WA...also suggest me how to use eps???

Code: Select all

``````CODE Deleted after AC
``````
Last edited by fR0D on Mon Feb 25, 2008 8:09 pm, edited 1 time in total.