Mathematical Equation

All submissions for this problem are available.
Problem Statement:
Prakhar is fond of solving the mathematical equations,one day his girlfriend asked him a new equation to solve.Equation is as follows:
K*(K+1) = 4*A*B + 2*max(A,B)
She also gives him an array(A) of pair(A,B) of size N,and asks Q queries,in each query she gives the value of K
and asks for the number of pairs which is present in the array(A) and satisfies the given equation for given K.
Prakhar got stucked in solving the given equation but he don't want to dissapoint his girlfriend,so he is asking for your help,can you help him out?
INPUT:
First line contains two space seperated integer N [size of the array(A)] and Q (number of query to ask).
Next N lines contains two space separated integers each lines denotes [information of pair(A,B)] of array(A).
Next line contains Q space sepereted integers (value of K).
OUTPUT:
For each Q, print a single integer in new line denoting inverse modulo of the number of pairs which satisfies the given equation and also present in the given array(A) with 10^9+9 or 1 if there is no such pair exist.
CONSTRAINTS:
1<=N<=10^5 1<=A[i],B[i]<=10^9 1<=Q<=10^5 1<=K<=2*10^9
SUBTASKS:
Subtask #1(100 points)
Original constraints
Example
Input:
4 3 1 1 2 2 13 5 1 1 1 4 2
Output:
1 1 500000005
Explanation:
Testcase 1 :
For first query for [ k=1 ] there exist no such pair so answer is 1.
For second query for [ k=4 ] there is exist a pair (2,2) which satisfies the equation so answer is inverse modulo of 1 with 10^9+9.
For third query for [ k=4 ] there is exist a pair (1,1) which satisfies the equation and present 2 times in
the array(A) so answer is inverse modulo of 2 with 10^9+9.
Author:  dk30390 
Tags  dk30390 
Date Added:  14072018 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions