#P6810. 「MCOI-02」Convex Hull 凸包

「MCOI-02」Convex Hull 凸包

Background

A contest needs an easy check-in problem.

Problem Description

Leasier was caught playing Minecraft, so he had to compute the value of the following expression.

$$\displaystyle\sum_{i = 1}^n \sum_{j = 1}^m \tau(i) \tau(j) \tau(\gcd(i, j))$$

Since the result may be very large, you only need to output the value modulo pp.

If you have questions about the mathematical symbols in this problem, please check the "Hint" section.

Input Format

One line with three integers n,m,pn, m, p.

Output Format

One line with one integer, representing the required value.

5 7 9
5

Hint

Constraints and Notes

This problem uses bundled testdata.

Subtask n,mn, m Score
11 1n,m1031 \leq n, m \leq 10^3 15pts15 \operatorname{pts}
22 1n,m1051 \leq n, m \leq 10^5 25pts25 \operatorname{pts}
33 1n,m1061 \leq n, m \leq 10^6 30pts30 \operatorname{pts}
44 No special constraints

For 100%100\% of the testdata, 1n,m2×1061 \leq n, m \leq 2 \times 10^6, and 1p1091 \leq p \leq 10^9.

Hint

As a beginner-friendly check-in problem, of course hints are provided.

  • \sum is the summation symbol. For example, i=1ni\displaystyle\sum_{i = 1}^n i means 1+2++n1 + 2 + \cdots + n.
  • τ\tau denotes the number of divisors. For example, τ(6)=4\tau(6) = 4.
  • gcd\gcd is the greatest common divisor. For example, gcd(12,15)=3\gcd(12, 15) = 3.

Notes

Minecraft OI Round 2 A

  • Maker: Leasier
  • Tester: happydef

Translated by ChatGPT 5