Sheldon and the mission
We are all familiar with the Sheldon's spot. For all those, who don't know about it, Sheldon's Spot is a place in Sheldon and Leonard's apartment which Sheldon has claimed as his own.
Sheldon defines his seat as "It is the singular location in space around which revolves my entire universe."
Sheldon relates his spot to himself in mathematical terms in "The Cushion Saturation": "In an ever-changing world it is a single point of consistency. If my life were expressed as a function on a
four-dimensional Cartesian coordinate system, that spot, at the moment I first sat on it, would be (0,0,0,0).
We are only concerned with the first two dimensions in this cartesian coordinate system that represents the plane in which Sheldon and people around him are walking. Sheldon is intitally standing on his spot, this represents the point (0,0) in the plane.
He is playing paint ball with his friends in this plane. He has a mission, in which, he needs to get to a coordinate (x1,y1) in the same plane. There are n other coordinates in this plane which he can use as intermediate points on his way to get to the point (x1,y1). If he is moving from point A to point B, then he has to walk along the line segment joining these points.
To move S units in this coordinate system, sheldon has to spend S*S Cal of energy. He wants the energy used to be minimum.
You task is to find a path such that the energy expenditure is minimum. After this print the minimum amount of energy needed.
The first line of input contains 3 integers, n, x1, y1.
Here n is the number of coordiantes in the plane and (x1,y1) is the destination point.
After this n lines follow, each containing 2 integers, x and y.
All these (x,y) pairs are n coordinates in the plane as stated in the problem statement.
The output contains a single line, the minimum amount of energy needed to get to the destination to complete the mission.
Sample Test cases
3 3 3
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions