Secret of the Sequence (Easy)
Time limit1sMemory limit1024 MB
Given n, p, q, r, s, and a_1, the task is to compute the sum of the first n terms of a sequence defined by a_(2i) = p*a_i + q and a_(2i+1) = r*a_i + s.
- Level
Easy2 of 10
- Topics
- Array, Simulation
- Solved
- No attempts yet
Problem
A sequence of length satisfies the following conditions.
Let . Print .
Input
The first line contains .
The second line contains positive integers , separated by spaces.
The third line contains the positive integer .
Output
Print the value of on the first line.