Hector & Safe house
Practice
4 (1 votes)
Easy Medium
Easy
Problem
31% Success 626 Attempts 30 Points 3s Time Limit 256MB Memory 1024 KB Max Code

DEA is currently struggling with a case of cooking Blue Crystal in Albuquerque. Hector Salamanca is a key witness of this case as he knows a lot of stuff regarding the Gang responsible for cooking & distribution of Blue Crystal.

"Hector Salamanca..? That Name rings a Bell!"

He agreed to tell everything he knows about this case to DEA. Gus Fring & Heisenberg are two people of the Gang which cook the Blue Crystal & they came to know about this. So, both of them want Hector to be dead before he tells anything to the DEA & Hank Schrader.

Heisenberg lives at a point (x1,y1) & Gus Fring at (x2,y2), both in Albuquerque.

Suddenly, DEA came to know that some of the Gang members want to kill Hector.

So, DEA is looking for a safe house along ax+by+c=0 (the border of Albuquerque), where they can ask Hector about the information he knew.

enter image description here

DEA also knows about the coordinates of Heisenberg & Gus & they want the safe house to be at a location which maximizes the difference between distance of the safe house to Heisenberg's House & distance of the safe house to Gus Fring's House.

Help DEA in finding the maximum absolute difference between the distance between safe house & Heisenberg’s house and distance between safe house & Gus Fring’s house i.e.

  • Maximum value of absolute((distance between safe house & Heisenberg’s house) - (distance between safe house & Gus Fring’s house)).

INPUT:

First line contains an integer T denoting the number of test case(s).

Each test case consists of two lines.

First line of each test case contains three integers a, b & c, describing the equation of the border of Albuquerque along which DEA is looking for a safe house.

Second line of each test case contains four integers x1, y1, x2, y2.

OUTPUT:

For each test case output the integral part of answer in separate line.

CONSTRAINTS

  • 1 ≤ T ≤ 106
  • -103 ≤ a,b,c ,x1,y1,x2,y2 ≤ 103

NOTE : Answer to the given problem always exists.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
6 votes
Tags:
MathematicsEasy-MediumMathematicsMathamatics
Points:30
3 votes
Tags:
MathematicsApprovedSimple-mathEasy-MediumMathematicsMathamatics
Points:30
7 votes
Tags:
Basic MathEasy-MediumMathematicsMathematics