## 11232 - Cylinder

Moderator: Board moderators

### 11232 - Cylinder

Is it just me or is the answer for the second test input not optimal....

My binary search gives a radius of 6.036325 - not 5 as the statement says - and that gives a volume of 1144.709. I have checked whether this cylinder is legal and it seems so...

Is it a quirk in the problem statement i got wrong?
Randers FC l
David Kjaer
New poster

Posts: 9
Joined: Sat Jul 07, 2007 5:47 pm
Location: Denmark

You can't cut out that circle. You need a sheet of paper of width at least 2r (the circle's diameter) to cut out a circle of radius r.
mf
Guru

Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland

What a mindnumbingly stupid mistake...

I agree... Thanks
Randers FC l
David Kjaer
New poster

Posts: 9
Joined: Sat Jul 07, 2007 5:47 pm
Location: Denmark

I still get WA on this one....

I lean towards a precision error, but there might be a hidden bug somewhere.

Here is my code..

Code: Select all
`Acc`
Last edited by David Kjaer on Sat Jul 07, 2007 9:55 pm, edited 1 time in total.
Randers FC l
David Kjaer
New poster

Posts: 9
Joined: Sat Jul 07, 2007 5:47 pm
Location: Denmark

I'd suggest to replace binary search by:
Code: Select all
`my = min(width/2, len/(2*PI+2)).`
mf
Guru

Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland

Thanks mate...

It seems to be a precision issue, caused by the binary search...
Randers FC l
David Kjaer
New poster

Posts: 9
Joined: Sat Jul 07, 2007 5:47 pm
Location: Denmark

well .. I tried to solve it by counting both the volumes if the paper is folded
horizontally and vertically. Then, choose the biggest one.
Afterall, all of sudden just give me more Wrong Answers...

Is it just me or is the answer for the second test input not optimal....

My binary search gives a radius of 6.036325 - not 5 as the statement says - and that gives a volume of 1144.709. I have checked whether this cylinder is legal and it seems so...

Is it a quirk in the problem statement i got wrong?

Actually, David, I have no idea why Binary Search used for...

my code is actually simple. Just give me a hand please.

Code: Select all
`code removed`
Last edited by dplt on Sun Jul 08, 2007 1:53 pm, edited 1 time in total.
dplt
New poster

Posts: 4
Joined: Thu Feb 15, 2007 4:30 pm
Location: Indonesia

Change all floats to doubles.

"Float" often causes precision error.

sohel
Guru

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

Also, please remove the solution from the board. It's too much of a spoiler.
sclo
Guru

Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm

sohel, you're right. I never expect such kind of error processing...

better check next time..

sclo, I've done it
dplt
New poster

Posts: 4
Joined: Thu Feb 15, 2007 4:30 pm
Location: Indonesia

i've got many WAs during the contest and after contest, can somebody tell me why my solution is wrong
here is my code:
Code: Select all
`//removed`
Last edited by arsalan_mousavian on Sun Jul 08, 2007 8:45 pm, edited 1 time in total.
In being unlucky I have the record.

arsalan_mousavian
Experienced poster

Posts: 111
Joined: Mon Jan 09, 2006 6:19 pm
Location: Tehran, Iran

Why do you think your binary search should work?
You could use a ternary search, but actually only if you use two different ternary searches, one for the case with horizontal roll up, the other for vertical roll up. But I suggest you think more about this problem, then you can find a solution without any ternary search.
Guru

Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

I am tired because of many WAs..

Can someone give some strickly I/O?

thanks very much..
Wei-Ming Chen
Experienced poster

Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

here some random sample...may it helpfull...

input
Code: Select all
`5 550 5080 8050 8020 5040 8045 505 64 52 30 0`

output
Code: Select all
`6.7816780.89727774.55414652.2762289.41811721.8215748.9968.7704.7450.824`

GOOD LUCK
Rocky

Rocky
Experienced poster

Posts: 124
Joined: Thu Oct 14, 2004 9:05 am

thanks.. but my outputs are same as yours..

I tried some other inputs, can someone check my outputs for me?

input
Code: Select all
`7 84 521 4754 6947 5232 784 554 775 8654 1007 8943 551 631 2523 440 0`

output
Code: Select all
`22.50650.2650.78512022.6966511.0388914.44550.26550.26598.17524725.716269.3926078.6950.7850.7852038.864`
Last edited by Wei-Ming Chen on Tue Jul 10, 2007 12:26 pm, edited 1 time in total.
Wei-Ming Chen
Experienced poster

Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

Next