Feedback | If you notice incorrect translations in Contester, please let author know.
|
|
Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Question by Ibrahim Mesecan.
Secret Number
Agent Genti has brought you a secret message.
You have to decode the message and find the number
(a telephone number or any secret number that you need)
in it. You know the secret function:
a[x-1] = b * a[x+1] - c
where b and c are the numbers
given. And the secret message will be sent
later. The message
is a series of numbers and the message is hidden
on the positions comply the given function.
You need to take the last digit of these numbers
(a[x] ) to form the new number.
Then, you multiply the number with k to get
the secret number. Note:
: The number might have at most seven
digits, so, if there are more than 7 digits,
take the first 7 digits.
Input specification
You are firstly given 4 numbers: The number of numbers
(n) and the numbers b, c and k. Then in the following
n lines, you will be given n numbers where each of the
number is between -3e4 and 3e4,
1 ≤ n ≤ 40,000
and 0 ≤ (b, c and k) ≤ 20 .
Output specification:
Show the secret number.
Sample Input I
10 2 9 3
37 7 23 8 13
15 -16 12 13 42
|
Sample Input II
10 3 5 3
79
88
55
31
28
78
11
64
83
23
|
Sample Output I
2208
|
Sample Output II
1749
|
Explanation:
a[0] = 37, a[1] = 7, a[2] = 23, b = 2
and c = 9 . And because 37 =
2 * 23 - 9 , the first number is 7 and its
last digit is 7.
- Because
7 = 2*8 - 9 , the second
number is 23: (and its last digit 3 is
taken)
- Lastly
15 = 2 * 12 - 9 , so, the third number
is -16 . And, its last digit 6 is
taken.
Then the number 736 is formed. In order to
find the searching number this number is
multiplied with k and we have the secret message:
2208 .
Для отправки решений необходимо выполнить вход.
|