10215 - The Largest/Smallest Box ...

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

Moderator: Board moderators

Yeamin Rajeev
New poster
Posts: 7
Joined: Wed Dec 12, 2001 2:00 am
Location: Bangladesh

10215 - The Largest/Smallest Box ...

Post by Yeamin Rajeev » Wed Dec 12, 2001 9:12 pm

Could anyone pls tell me what is the problem with prob10215 - largest/smallest boxes..

It seems to be a straightforward problem to find maxima/minima of the volume expression. But I'm getting a WA.

Yeamin Rajeev
New poster
Posts: 7
Joined: Wed Dec 12, 2001 2:00 am
Location: Bangladesh

Post by Yeamin Rajeev » Wed Dec 12, 2001 10:20 pm

Let myself answer my own Question - `Volume Can't be negative'!!!
``Fire in the Sky - can't you see that all my castles are burning?''

wyvmak
Experienced poster
Posts: 110
Joined: Thu Dec 13, 2001 2:00 am

Post by wyvmak » Thu Dec 13, 2001 6:54 pm

i understand volume<0, i still get WA.

Volume=x(W-2x)(L-2x).
that gives maximum at
x=[(W+L) - sqrt( W^2 -WL + L^2 )] /6

for minimum, i think the minimum volume should be 0.
so x(W-2x)(L-2x)=0
gives x=0 or x=L/2 or x=W/2
but isn't it if L>W, then we can't cut squares of L/2?
so isn't it always two values, namely 0 and min(L/2, W/2)?

can anyone tell me what's wrong here?

Orgi
New poster
Posts: 11
Joined: Mon Oct 29, 2001 2:00 am
Location: Bulgaria

Post by Orgi » Fri Dec 14, 2001 5:25 pm

Try coding the program in C and use
float for the numbers.. if you use double you could get WA.

Good luck.

Even
Learning poster
Posts: 75
Joined: Thu Nov 22, 2001 2:00 am
Location: Taiwan

Post by Even » Thu Jan 10, 2002 3:29 pm

Mm..your formula of max and min is the same with my...

I use C and double, and I got AC...

maybe you can try code in C

if you already use C, maybe you can send me you source...

Jorge Pinto
New poster
Posts: 11
Joined: Wed Jan 09, 2002 2:00 am
Location: Portugal

Post by Jorge Pinto » Thu Jan 10, 2002 6:24 pm

just solved it, got accepted
used C and doubles

if your using functions like pow or sqrt
use 2.0 and divide by 6.0 in the arguments

when using constants with doubles, use x.0

that should work

xenon
Learning poster
Posts: 100
Joined: Fri May 24, 2002 10:35 am
Location: Scheveningen, Holland

is this at all possible in Pascal

Post by xenon » Mon Jun 24, 2002 5:46 pm

I noticed that none of the 121 solvers of this problem did it in Pascal. I tried it too, but I'm getting WA's, whatever floating point datatype I use.

Do I realy have to dig up my rusty C knowledge, translate the code, steal some 32-bit compiler, and try my luck that way? From the foregoing discussion on this problem, I understand it's probably the only way...

Or can anyone tell me what's wrong with this code:
[pascal]
program p10215(input,output);

var
w,l,x,x1,x2,vol1,vol2:real;
begin
while not eof(input) do begin
readln(w,l);
if (w>l) then begin
x:=w;
w:=l;
l:=x;
end;
x1:=((l+w)-sqrt(sqr(l+w)-3.0*l*w))/6.0;
x2:=((l+w)+sqrt(sqr(l+w)-3.0*l*w))/6.0;
vol1:=x1*(w-2.0*x1)*(l-2.0*x1);
vol2:=x2*(w-2.0*x2)*(l-2.0*x2);
if (vol2<vol1) then x:=x1 else x:=x2;
writeln((round(x*1000.0)/1000.0):0:3,' 0.000 ',(w/2.0):0:3);
end;
end.[/pascal]

I tried different fp data-types, leaving out the round() function, etc. but nothing seems to work.

P.S. Does anyone know where to get a free, simple, easy to install, 32-bit C-compiler for WIN98?

Ivor
Experienced poster
Posts: 150
Joined: Wed Dec 26, 2001 2:00 am
Location: Tallinn, Estonia

Post by Ivor » Mon Jun 24, 2002 6:44 pm

If you want a C compiler, try

http://www.delorie.com/djgpp/

There's a nifty tool for choosing files you need. Don't forget RHIDE. :wink:

If you can't or don't want to you use this site, leave me a message and I can upload you the thing myself. (it is the same C compiler, I just happen to have it on CD)

Ivor

Caesum
Experienced poster
Posts: 225
Joined: Fri May 03, 2002 12:14 am
Location: UK
Contact:

Post by Caesum » Mon Jun 24, 2002 8:21 pm

I couldnt get a pascal version accepted, i had problems getting a c version accepted until i expanded
sqr(l+w)-3.0*l*w
into
l*l-l*w+w*w
.........
I hate these fp errors...... reminds me of 453 which gave me loads and loads of trouble......

xenon
Learning poster
Posts: 100
Joined: Fri May 24, 2002 10:35 am
Location: Scheveningen, Holland

got c code ac

Post by xenon » Mon Jun 24, 2002 11:14 pm

Thanx guys for the replies. After a frustrating hour of C coding (Kernighan & Ritchie was by my side all the time), using the judge as the only compiler, I finaly got my code accepted.
I'll check out djgpp soon, but I will stick to Pascal as much as possible; it flows from the fingers more easy, for me. And besides, I think it's discimination from the judge to only accept C on some problems :evil:

Derk
New poster
Posts: 23
Joined: Mon Mar 17, 2003 3:53 am
Location: Louisville, KY
Contact:

10215 - The Largest/Smallest Box...

Post by Derk » Sat Mar 29, 2003 8:13 am

I'm getting WA on 10215. I'm sure my calculus is right, and all the test inputs work too. Here's the set of I/O I've got right now:

Code: Select all

1 1
2 2
3 3
9999 9999
9999 1
1 9999
and the output:

Code: Select all

0.167 0.000 0.500
0.333 0.000 1.000
0.500 0.000 1.500
1666.500 0.000 4999.500
0.250 0.000 0.500
0.250 0.000 0.500
Can anyone confirm these values, and provide me with more from their working solution?

Eric
Learning poster
Posts: 83
Joined: Wed Sep 11, 2002 6:28 pm
Location: Hong Kong

Post by Eric » Wed Apr 09, 2003 2:53 pm

I get the same answer as Derk and WA also.
Can anyone help me?
Last edited by Eric on Sun Apr 13, 2003 5:32 am, edited 1 time in total.

bery olivier
Learning poster
Posts: 90
Joined: Sat Feb 15, 2003 1:39 am
Location: Paris, France
Contact:

Post by bery olivier » Wed Apr 09, 2003 3:49 pm

These outputs are correct.
input

Code: Select all

0.00001 0.00001
11111.11111 11111.11111
99999.00001 11111.11111
99999.99999 99999.99999
output

Code: Select all

0.000 0.000 0.000
1851.852 0.000 5555.556
2696.289 0.000 5555.556
16666.667 0.000 50000.000
Not AC yet Image AC at last Image

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski » Wed Apr 09, 2003 3:50 pm

You can print negative value ....
In this problem is impossible to get four positive values ....

DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

Eric
Learning poster
Posts: 83
Joined: Wed Sep 11, 2002 6:28 pm
Location: Hong Kong

Post by Eric » Wed Apr 09, 2003 4:05 pm

Dominik Michniewski wrote:You can print negative value ....
In this problem is impossible to get four positive values ....
What do you mean by negative value?
Can you give me some example?

Post Reply

Return to “Volume 102 (10200-10299)”