#P1998. DGF 等比求和

DGF 等比求和

Description

Given a number-theoretic function ff, define fnf^n as:

$$f^n=\begin{cases}f&n=1\\f^{n-1}* f &n\ge 2\end{cases}.$$

Here * denotes the Dirichlet convolution.

For positive integers n,mn, m, let the number-theoretic function g=f+f2++fmg=f+f^2+\cdots+f^m. Compute g(1),g(2),,g(n)g(1), g(2), \cdots, g(n), and take the answers modulo 109+710^9+7.

To control the output size, it is sufficient to output the value of k=1n(g(k)mod(109+7))\bigoplus_{k=1}^n(g(k)\bmod (10^9+7)).

Input Format

The first line contains two positive integers n,mn, m.

The second line contains nn non-negative integers, representing f(1),f(2),,f(n)f(1), f(2), \cdots, f(n) in order.

Output Format

Output one non-negative integer on a single line, representing k=1n(g(k)mod(109+7))\bigoplus_{k=1}^n(g(k)\bmod (10^9+7)).

10 10
1 1 4 5 1 4 1 9 1 9
1864

Hint

Constraints: For all testdata, it is guaranteed that 1n1061\le n\le 10^6, 1m1091\le m\le 10^9, and for 1in1\le i\le n, always 0f(i)1090\le f(i)\le 10^9.

In particular, f(1)=1f(1)=1, f(2)0f(2)\ne 0.

For Sample 1, the first 1010 terms of gg are 10,55,220,440,55,1540,55,2475,2695,82510, 55, 220, 440, 55, 1540, 55, 2475, 2695, 825.

The time limit is 4 times that of the "std". Please use fast I/O.

Translated by ChatGPT 5