Educational Codeforces Round 57 (Rated for Div. 2)


A. Find Divisible
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 10
3 14
1 10
Output
1 7
3 9
5 10
----------------------------------------------------------------------------------------------------
B. Substring Removal
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
abaa
Output
6
Input
7
aacdeee
Output
6
Input
2
az
Output
3
----------------------------------------------------------------------------------------------------
C. Polygon for the Angle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
54
50
2
178
Output
10
18
90
180
----------------------------------------------------------------------------------------------------
D. Easy Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
hhardh
3 2 9 11 7 1
Output
5
Input
8
hhzarwde
3 2 6 9 4 8 7 1
Output
4
Input
6
hhaarr
1 2 3 4 5 6
Output
0
----------------------------------------------------------------------------------------------------
E. The Top Scorer
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 6 3
Output
124780545
Input
5 20 11
Output
1
Input
10 30 10
Output
85932500
----------------------------------------------------------------------------------------------------
F. Inversion Expectation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 -1 -1
Output
499122179
Input
2
1 2
Output
0
Input
2
-1 -1
Output
499122177
----------------------------------------------------------------------------------------------------
G. Lucky Tickets
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
1 8
Output
6
Input
20 1
6
Output
1
Input
10 5
6 1 4 0 3
Output
569725
Input
1000 7
5 4 0 1 8 3 2
Output
460571165
----------------------------------------------------------------------------------------------------
