#P5572. [CmdOI2019] 简单的数论题

[CmdOI2019] 简单的数论题

Problem Description

Given n,mn,m, find the value of the following expression:

$$\sum\limits_{i=1}^n\sum\limits_{j=1}^m \varphi\left(\dfrac{{\rm lcm}(i,j)}{\gcd(i,j)}\right) \bmod 23333$$

Input Format

The first line contains an integer TT, which denotes the number of queries.

The next TT lines each contain two integers n,mn,m, representing one query.

Output Format

For each query, output one integer per line, which is the answer.

5
10 10
20 20
30 30
40 40
50 50

768
13312
16218
7160
9031
3
5 4
20 15
100 88
52
7572
21475

Hint

For all test cases, T3×104, mn5×104T\leq 3\times 10^4,\ m\leq n\leq 5\times 10^4.

Test Point ID n,mn,m\leq TT Time Limit Special Property
#1~2 100100 1s\texttt{1s}
#3~4 20002000 3×1043\times 10^4
#5~6 3×1043\times 10^4 50005000 2s\texttt{2s}
#7~8 5×1045\times 10^4 3×1043\times 10^4 n=mn=m
#9~10

Translated by ChatGPT 5