Problem Description
Let us define a sequence as below
F1=A
F2=B
Fn=C*Fn−2+D*Fn−1+⌊P/n⌋
Your job is simple, for each task, you should output Fn module 109+7.
Input
The first line has only one integer T, indicates the number of tasks.
Then, for the next T lines, each line consists of 6 integers, A , B, C, D, P, n.
1≤T≤200≤A,B,C,D≤1091≤P,n≤109
Sample Input
2
3 3 2 1 3 5
3 2 2 2 1 4
Sample Output
36
24
Source
2018 Multi-University Training Contest 7
Recommend
chendu
题意:给出ABCDPn,根据表达式求fn,
思路:用了分块+矩阵快速幂。
因为T<=20,所以n<=100005时ÿ