AVHNLIN - Editorial

PROBLEM LINK:

Practice
Contest

Author: Amit Kumar Pandey
Editorialist: Arkapravo Ghosh

DIFFICULTY:

SIMPLE

PREREQUISITES:

Math

PROBLEM:

We are given two lines a1x + b1x + c1 and a2x + b2y + c2, we need to find the intersection points of the lines.

EXPLANATION:

Now, given two lines a1x + b1x + c1 and a2x + b2y + c2, we can find the intersection of the lines by the formula:-
x’ = (b1c2 - b2c1)/(a1b2 - a2b1)
y’ = (c1a2 - a1c2)/(a1b2 - a2b1)

You just need to take care of the point that in Java infinity is printed as ‘Infinity’ and in other languages it’s printed different, e.g. ‘inf’ in C++. You need to print ‘Infinity’ to get AC.

You can find the author’s solution and my solution below. Hope this helps.:slight_smile:

AUTHOR’S AND EDITORIALIST’S SOLUTIONS:

Author’s solution can be found here.
Editorialist’s solution can be found here.

RELATED PROBLEMS:

*AVNRTRI

2 Likes