All submissions for this problem are available.
For a given prime number p find the number of all pairs (m, n) of positive integers such that 1 <= m, n <= p*(p-1) and p divides nm - mn. Output the result modulo 1000000007.
The first line contains a single positive integer T <= 100, the number of test cases. T test cases follow. The only line of each test case contains a prime number p , where 2 <= p <= 1012.
For each test case, output a single line containing the answer for the corresponding test case.
Input: 2 2 3 Output: 2 14
In the first test required pairs are (1, 1) and (2, 2).
In the second test case required pairs are (1, 1), (1, 4), (2, 2), (2, 4), (3, 3), (3, 6), (4, 1), (4, 2), (4, 4), (4, 5), (5, 4), (5, 5), (6, 3) and (6, 6).
|Tags||anton_lunyov, cook08, hard|
|Time Limit:||0.222849 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, 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, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.