ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1436. Billboard

Show all messages Hide all messages

Mathematics Behind the scene KNIGHT0X300 26 Feb 2013 18:47
There exist a closed form for the answer. hence the solution is O(K).
and it is easy to find with Maxima:

d2(x1,y1,x2,y2):=(x2-x1)^2+(y2-y1)^2;
x1: 0; /* even simpler if we assume x1=0 */
a1: d2(x1,y1,x,0); a2: d2(x2,y2,x,0); d: d2(x1,y1,x2,y2); /* the triangle */
ca: (a1+a2-d)/(2*sqrt(a1*a2)); /* cos of the angle */
s:solve(diff(ca,x)=0,x),ratsimp; /* solutions have y2-y1 as the denominator, so */
s1:solve(diff(ca,x)=0,x),y2=y1,ratsimp; /* let us solve it in this special case */