Codeforces Round 392 (Div. 2)


A. Holiday Of Equality
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
0 1 2 3 4
Output
10
Input
5
1 1 0 1 1
Output
1
Input
3
1 3 1
Output
4
Input
1
12
Output
0
----------------------------------------------------------------------------------------------------
B. Blown Garland
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
RYBGRYBGR
Output
0 0 0 0
Input
!RGYB
Output
0 1 0 0
Input
!!!!YGRB
Output
1 1 1 1
Input
!GB!RG!Y!
Output
2 1 1 0
----------------------------------------------------------------------------------------------------
C. Unfair Poll
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 3 8 1 1
Output
3 2 3
Input
4 2 9 4 2
Output
2 1 1
Input
5 5 25 4 3
Output
1 1 1
Input
100 100 1000000000000000000 100 100
Output
101010101010101 50505050505051 50505050505051
----------------------------------------------------------------------------------------------------
D. Ability To Convert
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
13
12
Output
12
Input
16
11311
Output
475
Input
20
999
Output
3789
Input
17
2016
Output
594
----------------------------------------------------------------------------------------------------
E. Broken Tree
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 3 5 7
3 2 4 3
Output
3
1 3 5 7
3 2 4 3
Input
4
1 3 2 3
3 4 5 1
3 2 3 3
Output
-1
Input
5
1 2 2 4
2 4 1 9
4 5 5 6
4 3 4 8
Output
5
1 2 2 4
2 4 1 9
4 5 1 2
4 3 2 6
Input
7
1 2 5 2
2 3 4 3
1 4 3 7
4 5 4 1
4 6 3 2
6 7 1 6
Output
7
1 2 5 2
2 3 2 1
1 4 3 7
4 5 3 0
4 6 3 2
6 7 1 6
----------------------------------------------------------------------------------------------------
F. Geometrical Progression
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 10
Output
10
Input
2 6 9
Output
12
Input
3 1 10
Output
8
Input
3 3 10
Output
2
----------------------------------------------------------------------------------------------------
