Tasks:
 
Task DescriptionDiscussion (0)
Task :: z-funkcija
Mr. Little Z is again given a hard math problem for rookies.

The task is: you are given a recursively defined array, so Fn = A* Fn-1 + B* Fn-2 + C* Fn-3

In other words, you are given the constants A, B, C, and values of the array F1 , F2 , F3 .

Help Mr. Little Z find the value of the array ( Fn ) for the given number n.

INPUT:
The first line of the standard input contains three numbers F1 , F2 and F3 that represent values of the array for n=1, 2, 3. Each of the numbers are from the interval [0, 10000]. The second line of the standard input contains three numbers C, B, A. Every number is from the interval [0, 10000]. Finally, the third line contains an integer N from the interval [1, 2000000000].

OUTPUT:
To the standard output in one line write the value of Fn modulus 10000. ( FN mod 10000).

Input:
1 1 1
1 1 1
5

Output:
5

Explanation:
From the input we have A=B=C=1 and F1 = F2 = F3 =1. So F4 = F3 + F2 + F1 =3; and F5 = F4 + F3 + F2 =5

Input:
0 1 2
3 2 1
2

Output:
1

Explanation: In this case A=1, B=2, C=3; F1 =0, F2 =1, F3 =2. So we just output F2 =1;
Submit Solution
:
:
Available Languages
Task info
Name:z-funkcija
Time:0.05 sec.
Memory:16 MB
#Tests:20
Author:Z
AddedBy: admin
Task Ratings
Difficulty:

4.4 (31 votes)
Quality:

4 (28 votes)
Acceptance Rate
Recent Submissions
Fastest Solutions
UserTime
admin 0.001 s.
redemption99 0.001 s.
stefan 0.002 s.
nemanja1990 0.002 s.
teodora 0.002 s.
oduleodule 0.003 s.
markee 0.003 s.
boba5551 0.004 s.
mario93 0.004 s.
mercedesmwit 0.004 s.
Solved By