All submissions for this problem are available.
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?
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).
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.
1<=N<=10^5 1<=A[i],B[i]<=10^9 1<=Q<=10^5 1<=K<=2*10^9
Subtask #1(100 points)
4 3 1 1 2 2 13 5 1 1 1 4 2
-1 1 500000005
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.
|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|
Fetching successful submissions