Reflections

All submissions for this problem are available.
Problem text...
Suppose we have a convex polygon of n vertices. One of the edges has a light
emitting point which emits a ray of light in a known direction. The edges of the
polygon are made of mirrors. As a result, when a ray of light falls upon an edge, it is
reflected to another direction according to the laws of reflection. So after a certain
number of reflections we can evaluate the point hit by ray. Our challenge here is to
evaluate that point. By the way, if the ray falls upon a vertex of the polygon, it is lost
forever.
Input
Input description...
The input session begins with two numbers 3<=v<=10, 0<=n<=1000, denoting the
number of vertices in the polygon and the number of reflections to simulate. After
that a line will follow containing (x,y), the position of the light emitting point, which
will always lie upon an edge (and will never coincide with any vertex) and
0<=t<360, the angle in degree between xaxis and the ray, measured in anticlockwise
direction, which is always valid. Next there be v lines each of which will
contain a vertex of the polygon ordered to the anticlockwise direction. All points will
be represented in x,y coordinate system with two digits after the decimal point. A
pair of zeros declares the end of the input session.
Output
Output description...
For every dataset, output the final point the array hits after n reflections with two
digits after the decimal point. Remember, the point should lie upon an edge of the
polygon. If the ray is lost forever within n reflections, output “lost forever…”. Output
for every dataset should start in a new line. Be extra cautious about precision
errors. Because if there is a vertex 4.00 and our ray passes through 4.001, we will
count it as “lost forever…”, as we are concerned with only two digits after the
decimal point.
Example
Input: 4 4 2.00 0.00 0.00 0.00 0.00 4.00 0.00 4.00 4.00 0.00 4.00 4 0 2.00 0.00 45.00 0.00 0.00 4.00 0.00 4.00 4.00 0.00 4.00 0 0 Output: Lost forever… 4.00 2.00
Author:  rushikesh30 
Tags  rushikesh30 
Date Added:  14022010 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, 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, PERL6, TEXT, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 