#P4593. [TJOI2018] 教科书般的亵渎
[TJOI2018] 教科书般的亵渎
Description
Xiao Dou likes playing games. He is now facing a situation in a game where each monster has health , and all monsters have distinct health values. Xiao Dou has an unlimited number of "Defile" cards. The effect of Defile is to deal damage to all monsters; if any monster dies, the spell is cast again. We consider a monster to be dead when its health reaches .
Each time Xiao Dou uses one "Defile," he gets some score. The score is calculated as follows: after using a single "Defile," every monster that is damaged by "Defile" grants Xiao Dou points, where is that monster’s health value before the damage is applied, and is the number of "Defile" cards needed to kill all monsters. Note: automatic re-casts of "Defile" caused by monster deaths do not count toward , and they do not increase Xiao Dou’s score.
Input Format
The first line contains an integer (), the number of test cases.
For each test case, the first line contains , , where is the maximum health value among the monsters, and is the number of health values that are missing.
The next lines each contain one number , indicating that there is no monster with health on the field.
Output Format
Output lines. The -th line contains the final score Xiao Dou can obtain in the -th test case, modulo .
2
10 1
5
4 2
1
2
415
135
Hint
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号