School Team Contest 1 (Winter Computer School 2010/11)


A. C*++ Calculations
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
1
5*a++-3*++a+a++
Output
11
Input
3
a+++++a
Output
8
----------------------------------------------------------------------------------------------------
B. Company Income Growth
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
10
-2 1 1 3 2 3 4 -10 -2 5
Output
5
2002 2005 2006 2007 2010
Input
3
-1 -2 -3
Output
0
----------------------------------------------------------------------------------------------------
C. Moon Craters
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1
2 2
4 1
5 1
Output
3
1 2 4
----------------------------------------------------------------------------------------------------
D. Cubical Planet
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
0 0 0
0 1 0
Output
YES
Input
1 1 0
0 1 0
Output
YES
Input
0 0 0
1 1 1
Output
NO
----------------------------------------------------------------------------------------------------
E. What Has Dirichlet Got to Do with That?
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
2 2 10
Output
Masha
Input
5 5 16808
Output
Masha
Input
3 1 4
Output
Stas
Input
1 4 10
Output
Missing
----------------------------------------------------------------------------------------------------
F. Pacifist frogs
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
5 3 5
2 3 4
1 2 3 4 5
Output
2
2 3
Input
1000000000 2 3
2 5
999999995 999999998 999999996
Output
1
2
----------------------------------------------------------------------------------------------------
G. Inverse Function
time limit per test: 5 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
17
int f(int n)
{
if (n < 100) return 17;
if (n > 99) return 27;
}
Output
99
Input
13
int f(int n)
{
if (n == 0) return 0;
return f(n - 1) + 1;
}
Output
13
Input
144
int f(int n)
{
if (n == 0) return 0;
if (n == 1) return n;
return f(n - 1) + f(n - 2);
}
Output
24588
----------------------------------------------------------------------------------------------------
H. Multiplication Table
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
10
Output
1  2  3  4  5  6  7  8  9
2  4  6  8 10 12 14 16 18
3  6  9 12 15 18 21 24 27
4  8 12 16 20 24 28 32 36
5 10 15 20 25 30 35 40 45
6 12 18 24 30 36 42 48 54
7 14 21 28 35 42 49 56 63
8 16 24 32 40 48 56 64 72
9 18 27 36 45 54 63 72 81
Input
3
Output
1  2
2 11
----------------------------------------------------------------------------------------------------
I. Tram
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
4 5
1 2
2 3
3 4
4 1
1 4
Output
2
2
1 3
----------------------------------------------------------------------------------------------------
J. Spelling Check
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abdrakadabra
abrakadabra
Output
1
3
Input
aa
a
Output
2
1 2
Input
competition
codeforces
Output
0
----------------------------------------------------------------------------------------------------
K. Testing
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
3 3 3
*.*
...
*..
Output
21
Input
4 5 4
.*.**
...**
**...
...**
Output
38
Input
2 2 1
.*
..
Output
4
----------------------------------------------------------------------------------------------------
