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

Mathematics Behind the scene
Posted by KNIGHT0X300 26 Feb 2013 18:47
There exist a closed form for the answer. hence the solution is O(K).
Re: Mathematics Behind the scene
Posted by ASK 3 Apr 2018 02:04
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 */