Fax McClad, Croneria's most courageous bounty hunter, often has weird dreams in his sleep. Sometimes, he dreams about his past experiences, and at other times, he has nightmares about problem statements that have no relation to the actual problem.
One night, Fax had a very, very bizarre dream about
:received an array of length
with elements numbered from , and he performed the sum operation on it. The sum operation takes in an array
and returns an array . Array has these two important properties:
- Array
and array are equal in length. - For all elements
, the element satisfies . Unimpressed with the result,
fed the result back in to the sum operation repeatedly, performing the operationtimes in total. At this point,
Suddenly, Fax wakes up! Disturbed by the abstract dream, he asks you to help solve the problem so he can focus on his bounty hunting.
Constraints
Subtask 1 [20%]
Subtask 2 [60%]
Subtask 3 [20%]
No additional constraints.
Input Specification
The first line will contain
The next line will contain the elements
The final line of input will contain
Output Specification
The array after performing
Each element should be outputted mod
Sample Input
5
4 2 8 1 1
2
Sample Output
4 10 24 39 55
Explanation for Sample Output
After one sum operation, the array is changed to:
4 6 14 15 16
After the second sum operation, the array is changed to:
4 10 24 39 55
Comments
this problem is so so so good.. hands down one of the best
So I submitted in pypy and got everything correct except for the last test case of the last batch is there any further optimizations i can implement?
same