Codeforces Round 901 (Div. 1)


A. Jellyfish and Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 2 1
1 2
3 4
1 1 10000
1
2
4 5 11037
1 1 4 5
1 9 1 9 8
1 1 1
2
1
Output
6
1
19
2
----------------------------------------------------------------------------------------------------
B. Jellyfish and Math
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
10
1 0 1 1 1
3 3 1 2 1
1 6 0 7 1
2 4 4 9 8
21 4 0 17 28
50 50 0 0 39
95 33 1 33 110
138 202 174 64 108
78 340 68 340 461
457 291 491 566 766
Output
1
-1
2
-1
-1
2
1
4
1
3
----------------------------------------------------------------------------------------------------
C. Jellyfish and EVA
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
3 2
1 2
1 3
7 8
1 2
1 3
1 4
1 5
2 6
3 6
4 6
6 7
10 20
1 2
1 3
1 4
1 5
1 6
2 6
2 7
2 8
2 9
3 4
3 7
3 8
3 10
4 6
4 8
4 10
6 10
7 8
7 9
7 10
Output
0.500000000000
0.625000000000
0.491666666667
----------------------------------------------------------------------------------------------------
D. Jellyfish and Miku
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 8
Output
5.200000000000
Input
10 98
Output
37.721155173329
----------------------------------------------------------------------------------------------------
E. Jellyfish and Hack
time limit per test: 8 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 10
Output
8
Input
8 32
Output
1280
----------------------------------------------------------------------------------------------------
F. Jellyfish and OEIS
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
2
Input
5
2 4 3 4 5
Output
38
Input
5
5 1 1 1 1
Output
0
----------------------------------------------------------------------------------------------------
G. Jellyfish and Inscryption
time limit per test: 2 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
6 8
0
1 2 10
1 6 6
2 8
3 10
0
1 2
1 3
2 4
2 5
3 4
3 5
4 6
5 6
Output
100000000000
Input
4 3
0
4 1000000
4 1000000
0
1 2
2 3
3 4
Output
2000000
Input
16 15
0
1 1 10
1 10 1
2 4
3 4
1 20 20
2 30
3 20
1 1 100
2 9
1 1 200
2 9
3 10
1 190 100
2 10
0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
Output
20000000005600
Input
9 9
0
1 1 200
3 200
3 200
3 200
3 200
1 200 200
3 200
0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
1 9
Output
80000000001000
Input
9 8
0
1 20 200
3 200
3 200
2 5
1 100 200
3 200
3 200
0
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
Output
60000000015000
Input
16 34
0
0
0
2 6
3 1
4 27
4 40
3 9
0
2 6
1 8 1
0
2 2
1 10 7
2 9
0
2 4
3 10
2 11
2 7
13 15
3 15
2 3
6 14
4 12
10 12
9 10
7 8
4 13
11 12
4 6
11 16
14 15
2 5
5 15
9 13
8 14
1 3
2 15
12 16
7 10
4 5
1 2
4 11
4 9
4 16
3 6
6 8
7 11
15 16
Output
133000000040
----------------------------------------------------------------------------------------------------
