Educational Codeforces Round 17


A. k-th divisor
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
Output
2
Input
5 3
Output
-1
Input
12 5
Output
6
----------------------------------------------------------------------------------------------------
B. USB vs. PS/2
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1 1
4
5 USB
6 PS/2
3 PS/2
7 PS/2
Output
3 14
----------------------------------------------------------------------------------------------------
C. Two strings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
hi
bob
Output
-
Input
abca
accepted
Output
ac
Input
abacaba
abcdcba
Output
abcba
----------------------------------------------------------------------------------------------------
D. Maximum path
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 1
1 -1 1
1 1 1
Output
7
Input
5
10 10 10 -1 -1
-1 10 10 10 10
-1 10 10 10 10
Output
110
----------------------------------------------------------------------------------------------------
E. Radio stations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 3 10
3 2 5
4 10 8
Output
1
Input
3 3
1 3 10
3 2 5
4 10 8
Output
2
Input
5 1
1 3 2
2 2 4
3 2 1
4 2 1
5 3 3
Output
2
Input
5 1
1 5 2
2 5 4
3 5 1
4 5 1
5 5 3
Output
5
----------------------------------------------------------------------------------------------------
F. Tree nesting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2
2 3
3 4
4 5
3
1 2
2 3
Output
3
Input
3
2 3
3 1
3
1 2
1 3
Output
1
Input
7
1 2
1 3
1 4
1 5
1 6
1 7
4
4 1
4 2
4 3
Output
20
Input
5
1 2
2 3
3 4
4 5
4
4 1
4 2
4 3
Output
0
----------------------------------------------------------------------------------------------------
