luogu#P5084. 轮换式
轮换式
Problem Description
Xiao Ben found that, for any letters, the “rotational form” they form can always be expressed as a linear combination of the basic rotational forms of degrees .
Unary basic rotational form: .
Binary: .
Ternary: .
Quaternary: .
And so on.
Similarly, for any letters, if you are given several of their basic rotational forms, you can determine the values of these letters.
However, Xiao Ben suddenly showed mercy: he only asks you to compute the sum of the -th powers of these letters modulo .
Input Format
The first line contains the number of letters and the exponent .
The next line contains positive integers. The -th number is , which from left to right are the values of the -variable basic rotational forms of degrees .
Output Format
Output one number, the required answer.
2 2
9 18
45
Hint
This problem has subtasks.
Subtask 1 (12 pts): .
Subtask 2 (28 pts): .
Subtask 3 (60 pts): .
For all data, .
Translated by ChatGPT 5