F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Sequence

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 3965    Accepted Submission(s): 1429


Problem Description
Let us define a sequence as below

$$\left\{\begin{eqnarray*}
F_1 &=& A \\
F_2 &=& B \\
F_n &=& C\cdot{}F_{n-2}+D\cdot{}F_{n-1}+\left\lfloor\frac{P}{n}\right\rfloor
\end{eqnarray*}\right.$$

  Your job is simple, for each task, you should output $F_n$ module $10^9+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 \leq T \leq 20 \\
0 \leq A, B, C, D \leq 10^9 \\
1 \leq P, n \leq 10^9$
 

Sample Input
2 3 3 2 1 3 5 3 2 2 2 1 4
 

Sample Output
36 24
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-16 19:56:11, Gzip enabled