Problem description James has been studying mathematical problems since he said goodbye to ACM/ICPC. First, he can prepare for the next postgraduate entrance exam. In addition, he can take this opportunity to help some students, especially beautiful teachers and sisters. This is not the case. The only girl in the class asked James for another math question. James was very happy to accept it. However, when he carefully reads the question, he finds that he will not do it. Now James said: If he says he doesn't understand it, isn't it a shame?
Therefore, he asks you to solve the problem privately. The problem is as follows:
Here are n numbers: A1, A2, A3, A4, A5 ...... An, these numbers change every unit time. Assume that the previous unit time number is a1', A2 ', a3 '...... An ', A [I] = A [I-1] '* K (when I = 1, a [1] = A [n]' * K) of the unit time), k indicates the given coefficient.
Now the question is, when the unit time t is calculated, what has the N numbers become? Because the number may be large, as long as you output the result after the number is 10 ^ 9 + 7.
The first line of input data is a positive integer T, indicating that there are T groups of test data;
Each data set has two rows. The first row contains three integers n, T, and K. N indicates the number of digits, t indicates the t unit time, and K indicates the coefficient; in the second line, enter n numbers of AI, which indicates the start time of each number.
[Technical Specification]
T <= 100
1 <= n <= 10 ^ 4
0 <= T <= 10 ^ 9 where T = 0 indicates the initial state
1 <= k <= 10 ^ 9
1 <= AI <= 10 ^ 9
Output for each group of data, please output the N digits after the t unit time to what, when the outputBetween every two numbersOutput a space. Do not output any extra space at the end of the line. For details, see the example.
Sample Input
23 2 51 2 33 0 51 2 3
Sample output
50 75 251 2 3
Note: Do not use long. Use _ int64
# Include <iostream> # include <stdlib. h> # include <string. h> using namespace STD ;__ int64 t; // _ int64 * arr [10005] ;__ int64 arr [10005]; // evaluate m ^ n % K _ int64 getmi (_ int64 M, _ int64 N, _ int64 K) {If (0 = m) return 0; if (0 = N) return 1 ;__ int64 T = 1 ;__ int64 TMP = m; while (n) {If (N & 1) T = T * TMP % K; TMP = TMP * TMP % K; n >>= 1;} return t;} int main () {__ int64 L = 1000000007; __int64 N, T, K; CIN> T; while (T --) {CIN> N> T> K ;__ int64 Templ = getmi (K, T, L); For (_ int64 I = 0; I <N; I ++) {CIN> arr [I]; arr [I] = arr [I] * Templ % L ;:int64 start = N-T % N; // first locate the position to be traversed. Cout <arr [start % N]; // output the n-1 for (_ int64 I = start + 1; I <start + N; I ++) {__ int64 temp = I; If (temp> = N) temp-= N; cout <"<arr [temp] ;}cout <Endl ;} return 0 ;}
Problem description James has been studying mathematical problems since he said goodbye to ACM/ICPC. First, he can prepare for the next postgraduate entrance exam. In addition, he can take this opportunity to help some students, especially beautiful teachers and sisters. This is not the case. The only girl in the class asked James for another math question. James was very happy to accept it. However, when he carefully reads the question, he finds that he will not do it. Now James said: If he says he doesn't understand it, isn't it a shame?
Therefore, he asks you to solve the problem privately. The problem is as follows:
Here are n numbers: A1, A2, A3, A4, A5 ...... An, these numbers change every unit time. Assume that the previous unit time number is a1', A2 ', a3 '...... An ', A [I] = A [I-1] '* K (when I = 1, a [1] = A [n]' * K) of the unit time), k indicates the given coefficient.
Now the question is, when the unit time t is calculated, what has the N numbers become? Because the number may be large, as long as you output the result after the number is 10 ^ 9 + 7.
The first line of input data is a positive integer T, indicating that there are T groups of test data;
Each data set has two rows. The first row contains three integers n, T, and K. N indicates the number of digits, t indicates the t unit time, and K indicates the coefficient; in the second line, enter n numbers of AI, which indicates the start time of each number.
[Technical Specification]
T <= 100
1 <= n <= 10 ^ 4
0 <= T <= 10 ^ 9 where T = 0 indicates the initial state
1 <= k <= 10 ^ 9
1 <= AI <= 10 ^ 9
Output for each group of data, please output the N digits after the t unit time to what, when the outputBetween every two numbersOutput a space. Do not output any extra space at the end of the line. For details, see the example.
Sample Input
23 2 51 2 33 0 51 2 3
Sample output
50 75 251 2 3