#P9157. 「GLR-R4」夏至

    ID: 10021 远端评测题 4000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数论洛谷原创O2优化素数判断,质数,筛法莫比乌斯反演容斥原理洛谷月赛

「GLR-R4」夏至

Background

  "The willow courtyard is quiet, people sleep in the daytime; in the daytime people sleep, the quiet wind, the willow courtyard."


  Old V said he prepared special zongzi for everyone, so Tianyi came;

  Tianyi came, so Ayling came;

  Ayling came, and Longya did not dare to stay away either;

  When almost half had arrived, the rest of the others all came too...

  So why do we have to make up cultural classes after the simulation performance training ends!

  "Tianyi, is this math teacher really teaching math?"

  "Moke, Ayling and I are counting on you!" Tianyi poked Moke's shoulder in the front row.

  "I'm about to derive it, I'm about to derive it..." It was probably the first time Moke had almost filled a draft paper, "I know I'm in a hurry, but let me not be in a hurry first... This feels like having a nightmare."


  Summer Solstice "Allow me to escape for a short while this one time, and sometimes try to use my back view, to face the uncertainty of the future."

Problem Description

  To check whether Moke is having a nightmare, please solve a simple math problem on the blackboard!

  Let the multiplicative function f(n)f(n) satisfy f(pc)=pgcd(c,k)f(p^c)=p^{\gcd(c,k)}, where kk is a given constant, pp is a prime, and cc is a positive integer. Now given n,m,kn,m,k, compute

$$\left(\sum_{i=1}^n\sum_{j=1}^mf(i\cdot j)\right)\bmod(10^9+7).$$

  For the definition of a multiplicative function, please refer to "Explanation of the Problem".

Input Format

The input contains only one line with three integers, representing n,m,kn,m,k.

Output Format

Output one integer per line, representing the value of the answer modulo 109+710^9+7.

2 2 64
9
5 5 64 
213
1234 1234 12
673319736
30000 10000000 2
836094021

Hint

Explanation of the Problem

  For a number-theoretic function f(n)f(n) and any two coprime positive integers x,yx,y, if it always holds that f(xy)=f(x)f(y)f(xy)=f(x)f(y), then f(n)f(n) is called a multiplicative function.

  When we know the values of a multiplicative function f(n)f(n) at all prime powers, we can compute its value at any positive integer. Specifically, for n>1n>1, suppose the unique factorization of nn is $n=p_1^{\alpha_1}p_2^{\alpha_2}\cdots p_k^{\alpha_k}$, then $f(n)=f(p_1^{\alpha_1})f(p_2^{\alpha_2})\cdots f(p_k^{\alpha_k})$.

Constraints and Conventions

For 100%100\% of the testdata, 1n1051\le n\le 10^5, 1m10101\le m\le 10^{10}, 1k1091\le k\le 10^{9}.

For different subtasks, the following constraints apply:

Subtask ID nn mm kk Subtask Score
11 103\le 10^3 103\le 10^{3} 55
22 =1=1 1010\le 10^{10} 109\le 10^9 1515
33 105\le 10^5
44 500\le 500 109\le 10^9 1010
55 105\le10^5 1010\le 10^{10} =1=1 1515
66 5×103\le 5\times 10^3 109\le 10^9 109\le 10^9
77 5×104\le 5\times 10^4 108\le 10^8
88 105\le 10^5 1010\le 10^{10} 1010

Translated by ChatGPT 5