Codeforces Round 174 (Div. 2)


A. Cows and Primitive Roots
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
1
Input
5
Output
2
----------------------------------------------------------------------------------------------------
B. Cows and Poker Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
AFFAAA
Output
4
Input
3
AFI
Output
1
----------------------------------------------------------------------------------------------------
C. Cows and Sequence
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 1
3
2 3
2 1
3
Output
0.500000
0.000000
1.500000
1.333333
1.500000
Input
6
2 1
1 2 20
2 2
1 2 -3
3
3
Output
0.500000
20.500000
14.333333
12.333333
17.500000
17.000000
----------------------------------------------------------------------------------------------------
D. Cow Program
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 4 1
Output
3
6
8
Input
3
1 2
Output
-1
-1
----------------------------------------------------------------------------------------------------
E. Coin Troubles
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2 17
3 1 2 5
4 2
3 4
Output
3
Input
3 2 6
3 1 1
1 2
2 3
Output
0
Input
3 2 10
1 2 3
1 2
2 1
Output
0
----------------------------------------------------------------------------------------------------
