#P8926. 「GMOI R1-T3」Number Pair

    ID: 9139 远端评测题 2000ms 256MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>数学数论O2优化最大公约数 gcd

「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 P≤gcd⁡(x,y)≤QP \le \gcd(x,y) \le Q (it is guaranteed that P≤QP \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: 1≤k≤10161 \le k \le 10^{16}, 1≤T≤501 \le T \le 50, 1≤P≤Q≤2×1091 \le P \le Q \le 2\times 10^9.

Test Point kk TT PP QQ Total Score
1∼31\sim 3 k≤3k \le 3 T=1T=1 P=1P=1 Q=1Q=1 1515
4∼84\sim 8 k≤100k \le 100 T≤8T \le 8 P≤30P \le 30 Q≤30Q \le 30
9∼139\sim 13 k≤103k \le 10^3 T≤50T \le 50 P≤500P \le 500 Q≤500Q \le 500 2525
14∼1814\sim 18 k≤1012k \le 10^{12} P≤104P \le 10^4 Q≤104Q \le 10^4 1515
19∼2219\sim 22 k≤1013k \le 10^{13} P≤106P \le 10^6 Q≤106Q \le 10^6 1212
23∼2823\sim 28 k≤1016k \le 10^{16} P≤2×109P \le 2\times10^9 Q≤2×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