Educational Codeforces Round 7


A. Infinite Sequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
2
Input
5
Output
2
Input
10
Output
4
Input
55
Output
10
Input
56
Output
1
----------------------------------------------------------------------------------------------------
B. The Time
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
23:59
10
Output
00:09
Input
20:20
121
Output
22:21
Input
10:10
0
Output
10:10
----------------------------------------------------------------------------------------------------
C. Not Equal on a Segment
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 4
1 2 1 1 3 5
1 4 1
2 6 2
3 4 1
3 4 2
Output
2
6
-1
4
----------------------------------------------------------------------------------------------------
D. Optimal Number Permutation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
1 1 2 2
Input
1
Output
1 1
----------------------------------------------------------------------------------------------------
E. Ants in Leaves
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
12
1 2
1 3
1 4
2 5
2 6
3 7
3 8
3 9
8 10
8 11
8 12
Output
6
Input
2
2 1
Output
1
----------------------------------------------------------------------------------------------------
F. The Sum of the k-th Powers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1
Output
10
Input
4 2
Output
30
Input
4 3
Output
100
Input
4 0
Output
4
----------------------------------------------------------------------------------------------------
