Codeforces Round 183 (Div. 1)


A. Lucky Permutation Triple
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
Output
1 4 3 2 0
1 0 2 4 3
2 4 0 1 3
Input
2
Output
-1
----------------------------------------------------------------------------------------------------
B. Rectangle Puzzle II
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 9 5 5 2 1
Output
1 3 9 7
Input
100 100 52 50 46 56
Output
17 8 86 92
----------------------------------------------------------------------------------------------------
C. Minimum Modular
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 0
0 2 3 6 7 12 18
Output
13
Input
7 1
0 2 3 6 7 12 18
Output
7
----------------------------------------------------------------------------------------------------
D. Rotatable Number
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 11
Output
10
Input
5 8
Output
-1
----------------------------------------------------------------------------------------------------
E. Random Ranking
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 6
4 9
Output
0.9200000000 0.080 
0.080 0.9200000000 
Input
8
0 2
1 3
2 4
3 5
4 6
5 7
6 8
7 9
Output
0.875 0.125 0 0 0 0 0 0 
0.125 0.750 0.125 0 0 0 0 0 
0 0.125 0.750 0.125 0 0 0 0 
0 0 0.125 0.750 0.125 0 0 0 
0 0 0 0.125 0.750 0.125 0 0 
0 0 0 0 0.125 0.750 0.125 0 
0 0 0 0 0 0.125 0.750 0.125 
0 0 0 0 0 0 0.125 0.875 
----------------------------------------------------------------------------------------------------
