#P8926. 「GMOI R1-T3」Number Pair

「GMOI R1-T3」Number Pair

Problem Description

We define a pair of numbers (x,y)(x,y) that satisfies the following conditions as a "wonderful number pair":

k×gcd(x,y)=lcm(x,y)k \times \gcd(x,y)=\operatorname{lcm}(x,y), and Pgcd(x,y)QP \le \gcd(x,y) \le Q (it is guaranteed that PQP \le Q).

There are TT test cases. For each test case, given three numbers k,P,Qk,P,Q, find the number of pairs (x,y)(x,y) that satisfy the conditions.

Output the answer modulo 109+710^9+7.

Input Format

This problem has multiple test cases.

The first line contains an integer TT, representing the number of test cases.

The next TT lines each contain three integers k,P,Qk,P,Q.

Output Format

For each test case, output the corresponding answer, one per line.

5
10 1 3
30 1 5
997 24 35
34 39 99
210 1000 1001
12
40
24
244
32

Hint

Note that the time limit is not usual.

For 100%100\% of the testdata: 1k10161 \le k \le 10^{16}, 1T501 \le T \le 50, 1PQ2×1091 \le P \le Q \le 2\times 10^9.

Test Point kk TT PP QQ Total Score
131\sim 3 k3k \le 3 T=1T=1 P=1P=1 Q=1Q=1 1515
484\sim 8 k100k \le 100 T8T \le 8 P30P \le 30 Q30Q \le 30
9139\sim 13 k103k \le 10^3 T50T \le 50 P500P \le 500 Q500Q \le 500 2525
141814\sim 18 k1012k \le 10^{12} P104P \le 10^4 Q104Q \le 10^4 1515
192219\sim 22 k1013k \le 10^{13} P106P \le 10^6 Q106Q \le 10^6 1212
232823\sim 28 k1016k \le 10^{16} P2×109P \le 2\times10^9 Q2×109Q \le 2\times10^9 1818

This problem guarantees that kk is generated randomly, and there is no extreme testdata intended to make it difficult. The time limit has already been set to twice that of the standard solution, so please feel assured.

Translated by ChatGPT 5