Codeforces Round 323 (Div. 1)


A. GCD Table
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 1 2 3 4 3 2 6 1 1 2 2 1 2 3 2
Output
4 3 6 2
Input
1
42
Output
42 
Input
2
1 1 1 1
Output
1 1 
----------------------------------------------------------------------------------------------------
B. Once Again...
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
3 1 4 2
Output
5
----------------------------------------------------------------------------------------------------
C. Superior Periodic Subarrays
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
7 1 2 3
Output
2
Input
2
2 1
Output
1
Input
3
1 1 1
Output
6
----------------------------------------------------------------------------------------------------
D. Number of Binominal Coefficients
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
7
Output
3
Input
3 1
9
Output
17
Input
3 3
9
Output
0
Input
2 4
5000
Output
8576851
----------------------------------------------------------------------------------------------------
E. Boolean Function
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
?
2
1 0 1 0 1
0 1 1 0 1
Output
2
Input
(A)?(?)
1
1 1 0 0 0
Output
4
Input
((?)&(?))|((?)&(?))
0
Output
4096
Input
b
1
1 0 1 1 1
Output
1
----------------------------------------------------------------------------------------------------
