Codeforces Round 131 (Div. 2)


A. System of Equations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 3
Output
1
Input
14 28
Output
1
Input
4 20
Output
0
----------------------------------------------------------------------------------------------------
B. Hometask
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
0
Output
0
Input
11
3 4 5 4 5 3 5 3 4 4 0
Output
5554443330
Input
8
3 2 5 1 5 2 2 3
Output
-1
----------------------------------------------------------------------------------------------------
C. Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
1
0
Output
1
Input
5
2 2 1 1 3
1 5
2 5 1
2 5 4
1 5
0
Output
7
----------------------------------------------------------------------------------------------------
D. Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
0 0 0 0 0 0 0 0 0 1
Output
1
Input
2
1 1 0 0 0 0 0 0 0 0
Output
1
Input
3
1 1 0 0 0 0 0 0 0 0
Output
36
----------------------------------------------------------------------------------------------------
E. Relay Race
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
5
Output
5
Input
2
11 14
16 12
Output
53
Input
3
25 16 25
12 18 19
11 13 8
Output
136
----------------------------------------------------------------------------------------------------
