Codeforces Beta Round 84 (Div. 1 Only)


A. Lucky Sum of Digits
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
11
Output
47
Input
10
Output
-1
----------------------------------------------------------------------------------------------------
B. Lucky Probability
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 10 1 10 2
Output
0.320000000000
Input
5 6 8 10 1
Output
1.000000000000
----------------------------------------------------------------------------------------------------
C. Lucky Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 4
3 1 2
1 4 7
Output
16
Input
4
1 2 4
1 3 47
1 4 7447
Output
24
----------------------------------------------------------------------------------------------------
D. Lucky Sorting
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4 7
Output
0
Input
3
4 2 1
Output
1
1 3
Input
7
77 66 55 44 33 22 11
Output
7
1 7
7 2
2 6
6 7
3 4
5 3
4 5
----------------------------------------------------------------------------------------------------
E. Lucky Interval
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7 4
Output
17
Input
4 7
Output
14
----------------------------------------------------------------------------------------------------
