Codeforces Round 323 (Div. 2)


A. Asphalting Roads
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 1
1 2
2 1
2 2
Output
1 4 
Input
1
1 1
Output
1 
----------------------------------------------------------------------------------------------------
B. Robot's Task
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 2 0
Output
1
Input
5
4 2 3 0 1
Output
3
Input
7
0 3 1 0 5 2 6
Output
2
----------------------------------------------------------------------------------------------------
C. 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 
----------------------------------------------------------------------------------------------------
D. 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
----------------------------------------------------------------------------------------------------
E. 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
----------------------------------------------------------------------------------------------------
