report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Line intersection - MarisaOJ: Marisa Online Judge

Line intersection

Time limit: 1000 ms
Memory limit: 256 MB
Given $q$ questions. Each question give you four points $A(x_A,y_A),B(x_B,y_B),C(x_C,y_C),D(x_D,y_D)$. Find the point of intersection of lines $AB$ and $CD$. It is guaranteed that there is only one intersection point. ### Input - The first line contains an integer $q$. - The next $q$ lines, each line contains eight integers $x_A,y_A,x_B,y_B,x_C,y_C,x_D,y_D$. ### Output - Print $q$ lines. Each line, print the point of intersection for the corresponding question. Your answer will be considered correct if its absolute or relative error does not exceed $10^{-3}$. In other words, your answer, $x$, will be compared to the correct answer, $y$. If $|x-y| < 10^{-3}$, then your answer will be considered correct. ### Constraints - $1 \le q \le 10^5$. - $-10^6 \le x, y \le 10^6$. ### Example Input: ``` 1 0 0 1 1 1 0 0 1 ``` Output: ``` 0.5 0.5 ```
Geometry
Three points
Line segment intersection
Line intersection
Quadrilateral classification
Point location
Triangle classification
Polygon area
Distance to polygon
Convex hull
Perpendicular pairs
Maximum quadrilateral
Catching butterflies
Topic
Geometry
Rating 1100
Solution (0) Solution