Given \(q\) queries, you must find answer for each query.
For each query, you are given an positive integer \(n, k\ (1 \leq k \leq n \leq 10^{13})\).
Count the number of arrays \(a[]\) of size \(k\) that satisfies:
- \(1 \leq a_1 < a_2 < \dots < a_k \leq n\)
- \(a_i \times a_{i+1}\) is a perfect square \(\forall 1 \leq i < n\)
Since the result can be large, output it under modulo \(977555333311111\).
Input
-
The first line contains a single integer \(\lambda\) is the number of this subtask.
-
The second line contains a positive integer \(q\).
-
The next \(q\) lines, the \(pth\) query will contain \(2\) positive integers \(k, n\).
Output
- In the p-th line, output a single number is the answer for query \((n_p, k_p)\) under modulo \(977555333311111\).
Scoring
-
Subtask 1: \(10.00\)% tests \(\lambda = 1\) for \(1 \leq q \leq 100.000\) queries of \(1 \leq k \leq \log_2(n) \leq n \leq \large \frac{10^{11}}{q}\)
-
Subtask 2: \(10.00\)% tests \(\lambda = 2\) for \(1 \leq q \leq 100\) queries of \(1 \leq k \leq n \leq 100\).
-
Subtask 3: \(10.00\)% tests \(\lambda = 3\) for \(1 \leq q \leq 10\) queries of \(1 \leq k \approx \sqrt{n} \leq n \leq 10^{10}\)
-
Subtask 4: \(10.00\)% tests \(\lambda = 4\) for \(1 \leq q \leq 10\) queries of \(1 \leq k \approx \sqrt[3]{n} \leq n \leq 10^{10}\)
-
Subtask 5: \(10.00\)% tests \(\lambda = 5\) for \(1 \leq q \leq 100\) queries of \(1 \leq k \leq n \leq 2^{22}\) and \(k, n\) are power of two.
-
Subtask 6: \(10.00\)% tests \(\lambda = 6\) for \(1 \leq q \leq 1000\) queries of \(1 \leq k \approx \sqrt{n} \leq n \leq 10^{7}\)
-
Subtask 7: \(10.00\)% tests \(\lambda = 7\) for \(1 \leq q \leq 1000\) queries of \(1 \leq k \approx \sqrt[3]{n} \leq n \leq 10^{7}\)
-
Subtask 8: \(10.00\)% tests \(\lambda = 8\) for \(1 \leq q \leq 10.000\) queries of \(1 \leq k \approx \sqrt{n} \leq n \leq 10^{4}\)
-
Subtask 9: \(10.00\)% tests \(\lambda = 9\) for \(1 \leq q \leq 10.000\) queries of \(1 \leq k \approx \sqrt[3]{n} \leq n \leq 10^{4}\)
-
Subtask 10: \(10.00\)% tests \(\lambda = 10\) for \(q = 1\) query of \(1 \leq k \leq n \leq 10^{13}\)
Intended solution: \(O(\sqrt{n} \log \log \sqrt{n})\) per query.
Example
Test 1
Input
10
1
2 1
Output
2
Note
There are \(2\) satisfied arrays {\(1\)}, {\(2\)}
Test 2
Input
2
3
10 2
25 2
27 3
Output
4
16
12
Note
In the first query, there are \(4\) satisfied arrays: {\(1, 4\)}, {\(1, 9\)}, {\(2, 8\)}, {\(4, 9\)}.
In the second query, there are \(16\) satisfied arrays: {\(1, 4\)}, {\(1, 9\)}, {\(1, 16\)}, {\(1, 25\)}, {\(2, 8\)}, {\(2, 18\)}, {\(3, 12\)}, {\(4, 9\)}, {\(4, 16\)}, {\(4, 25\)}, {\(5, 20\)}, {\(6, 24\)}, {\(8, 18\)}, {\(9, 16\)}, {\(9, 25\)}, {\(16, 25\)}.
In the third query, there are \(12\) satisfied arrays: {\(1, 4, 9\)}, {\(1, 4, 16\)}, {\(1, 4, 25\)}, {\(1, 9, 16\)}, {\(1, 9, 25\)}, {\(1, 16, 25\)}, {\(2, 8, 18\)}, {\(3, 12, 27\)}, {\(4, 9, 16\)}, {\(4, 9, 25\)}, {\(4, 16, 25\)}, {\(9, 16, 25\)}.
Test 3
Input
1
10
123456789 1
234567890 2
345678901 3
456789012 4
567890123 5
678901234 6
789012345 7
890123456 8
901234567 9
12345678 10
Output
123456789
1273061974
2324814700137
497809922458658
162321859768410
154368725290449
443251450189935
281974354563468
117720773712544
148331601579738
Bình luận
The tests might not be strong enough but the second version with stronger test cases close to the time limit might be made later in December
1 bình luận nữa