Swallow Messenger
InterviewTime limit2sMemory limit1024 MB
Given N points and M allowed integer slopes, count the ordered pairs of distinct points that lie on a common line with one of those slopes.
Problem
Hanyang wants to tie a letter to one of his swallows and send it to Sejong.
However, the swallows Hanyang raises are stubborn. Each one flies only along a straight path from Hanyang's position, following its own fixed slope.
Sejong must stand on this straight path to receive Hanyang's letter, which makes swallow communication possible.
You are given coordinates where Hanyang and Sejong can be placed.
Count every way to place the two of them so that swallow communication is possible.
Input
The first line contains and , separated by a space. (, )
The second line contains slopes , separated by spaces. All values are distinct. ()
The next lines each contain the and coordinates of point , separated by a space. All coordinates are distinct. ()
All input values are integers.
Output
Print the number of ways to place Hanyang and Sejong so that swallow communication is possible.
Hanyang and Sejong cannot be placed on the same coordinate.
Hint
In mathematics, slope is a number that describes how steeply a line is tilted. In the Cartesian coordinate system, the slope of a line can be written as follows.