Friend in need is a friend indeed
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
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 |
---|---|
|
|
|
|
Brain booster - 1
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 10
- Start at
- 2023-12-31 13:15
- End at
- 2023-12-31 17:15
- Duration
- 4.0 hour(s)
- Host
- Partic.
- 36