#P6202. [USACO07CHN] Summing Sums G
[USACO07CHN] Summing Sums G
Problem Description
cows () have just learned a lot about cryptography. At last, they created a cow-only encryption method. Because they lack experience, their encryption method is very simple.
The -th cow holds the -th digit of the code, which is initially (). During encryption, the -th cow computes the sum of the numbers of all other cows, and takes this sum modulo . After all cows finish computing, each cow replaces her original number with the number she computed. That is,
In this way, they complete one encryption.
In November, the cows told this encryption method to Carmen the moose. After thinking for a while, Carmen said: "Your algorithm is still very primitive. To achieve an encryption effect, you need to repeat this encryption process times ()."
The cows are lazy, so they gave this task to you.
Input Format
The first line contains two integers .
The next lines each contain one integer. The -th line contains .
Output Format
Output lines. The -th line contains one integer, representing after encryptions.
3 4
1
0
4
26
25
29
Hint
After each encryption, is as follows:
| Number of times | |||
|---|---|---|---|
| 0 | 1 | 0 | 4 |
| 1 | 4 | 5 | 1 |
| 2 | 6 | 9 | |
| 3 | 14 | 15 | 11 |
| 4 | 26 | 25 | 29 |
Translated by ChatGPT 5