#P3312. [SDOI2014] 数表

    ID: 2361 远端评测题 1500ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2014山东最大公约数,gcd莫比乌斯反演前缀和

[SDOI2014] 数表

Description

There is an n×mn\times m table of numbers. The value at row ii and column jj (1in1\le i\le n, 1jm1\le j\le m) equals the sum of all natural numbers that divide both ii and jj. Given aa, compute the sum of all numbers in the table that are not greater than aa.

Input Format

The input contains multiple test cases.

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

Each of the next QQ lines contains three integers nn, mm, aa (a109|a|\le 10^9), describing one test case.

Output Format

For each test case, output one line with a single integer: the answer modulo 2312^{31}.

2
4 4 3
10 10 5
20
148

Hint

Constraints and Conventions

For all testdata, 1n,m1051\le n,m\le 10^5, 1Q2×1041\le Q\le 2\times 10^4.

Translated by ChatGPT 5