Friend in need is a friend indeed
Time Limit: 1.0 s
Memory Limit: 64.0 MB
Description
In today’s class Emon’s math teacher discussed about XY coordinate and the equation of the straight line and has given some homework also. But there will be a match between his favourite club Barcelona and its rival Real Madrid tonight and Emon doesn’t want to miss the match. So as a friend he is requesting you to do his homework. The description of the homework follows-
You are given a string in the form of the equation of a straight line \(y=mx \pm c\) without any space. Where \(m\) is the slope of the straight line, \(c\) is the height at which the line crosses the \(y\) axis. for example: \(y=-21x+3\), \(y=4x-521\)
You have to answer q query . Each query contains a point \((X,Y)\) on the \(XY\) coordinate. Your task is to find if the point \((X,Y)\) is on the given straight line or not.
Will you do this favour to him ?
A point \((X,Y)\) is on line \(y=mx+c\) if \(Y=mX+c\)
Note: m and c are guaranteed to be integers in range \(-10^5\) to \(10^5\)
Input
First line of a test case contains a string S which represents the equation of straight line.
Next line contains an integer Q : number of queries
Each of next Q lines contains two integers. X and Y – which represents the point
1 <= Q <=1000
\(-10^5\) <= X,Y <= \(10^5\)
Output
Print q lines , each line should contain a string “YES” or “NO” for each query. Print “YES” if the point is on the line and “NO” otherwise.
Sample
Input | Output |
---|---|
|
|
|
|
Information
- ID
- 1015
- Difficulty
- 7
- Category
- (None)
- Tags
- (None)
- # Submissions
- 34
- Accepted
- 7
- Accepted Ratio
- 21%
- Uploaded By
Related
In following contests: