Use ternary search. Simple math problem. You should just maximise one function. Unfortunately, I don't know how to maximize it. So I can search :) H/2*sin(a)  h*tan(a) Can anybody tell me how to maximize it? Oh, I recalled my differential calculus. how you got h*tan(a) in your formula ??? why it works ?? As of the definition of the tangent, there must be h/tan(a) but this gives wroung results ! why ? It's hard to dispute with you! :)))) Can anyone explain this problem? I didn't understand why we have L, I think we don't need it, or what should we find at all. or what does it mean, that the width is zero there. You gotta find the dependence of your length with the angle. It looks like two variable formula. What's mean this problem? help to solve please this problem on with ++. I will be very grateful! it is possible to write on mail juliauhova@mail.ru 12 234 1344 80.7365278858 10 11 12 0 1 999 1000 487.6458506118 In my opinion the problem statement is quite unclear. Although it is said in it that the book might fall at some point it never does (even if it goes beyond the line where physic laws say it falls). The problem my team was solving during the contest was to determine when the book will fall if it falls (and at what X this would happen), and if it doesn't  what is the furthest point to the left the middle of it can go while sliding over the shelf (the original problem). Please change the statement so other people are not confused by this ambiguity. I totally agree with Alexander Georgiev. Problem statement is really unclear. +1 The value of L is noninformation. The text suggests the book may fall, but to solve the problem you have to pretend it doesn't (zero gravity, weightless book, magical forces). I propose that the problem setter should shelve books for the rest of his life and stay away from programming. Does it mean that we need to calculate the maximal displacement where the center goes even when it falls? And after the book starts falling must we consider that the book just rotates around the edge of the bookshelf? or it slides a little backwards. Some more explanation of the problem text and maybe some hints would be welcomed. Thank you. L.E. Now I get WA 8. I don't think there is a problem with precision, or something like that. Some more samples to pass this test? Does L have to be used at anything? I believe not since L>H. L.L.E. My WA 8 was from a division by 2 of an integer variable, which I assigned to a double variable. The problem was solved when I divided by 2.0 Edited by author 25.03.2010 20:20 
