#P10263. [GESP202403 八级] 公倍数问题

[GESP202403 八级] 公倍数问题

Background

Related multiple-choice and true/false questions: https://ti.luogu.com.cn/problemset/1148.

Problem Description

Xiao A wrote an N×MN \times M matrix AA. We cannot see this matrix, but we know that the element Ai,jA_{i,j} in row ii and column jj is a common multiple of ii and jj (i=1,,Ni=1,\dots,N, j=1,,Mj=1,\dots,M). Now there are KK children. The kk-th child wants to know: in matrix AA, what is the maximum number of elements that can be equal to kk (k=1,2,,Kk=1,2,\dots,K). Please help them compute the answers.

Note: the answers for different children are independent. For example, if some positions can be xx and also can be yy, then those positions can satisfy both children xx and $y at the same time.

For convenience, you only need to output k=1Kk×ansk\sum_{k=1}^{K}{k \times \texttt{ans}_k}, where ansk\texttt{ans}_k denotes the answer that the kk-th child is interested in.

Input Format

The first line contains three positive integers N,M,KN, M, K.

Output Format

Output one line: k=1Kk×ansk\sum_{k=1}^{K}{k \times \texttt{ans}_k}.

Please note that this number may be very large. If you are using C++, consider using data types such as long long to store the answer.

2 5 2
9
100 100 100
185233

Hint

Sample 1 Explanation

Only A1,1A_{1,1} can be 11; all the others cannot.

A1,1,A1,2,A2,1,A2,2A_{1,1}, A_{1,2}, A_{2,1}, A_{2,2} can all be 22, and the others cannot.

So the answer is 1×1+2×4=91 \times 1 + 2 \times 4 = 9.

Constraints

For 30%30\% of the testdata, N,M,K10N, M, K \leq 10.

For 60%60\% of the testdata, N,M,K500N, M, K \leq 500.

For 100%100\% of the testdata, N,M105N, M \leq 10^5, and K106K \leq 10^6.

Translated by ChatGPT 5