PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000120. Tô màu xen kẽ (Paint the Array)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tô màu xen kẽ (Paint the Array)
Paint the Array
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers , choose a positive integer . Color every array element divisible by red and all other elements blue. The coloring is beautiful if every adjacent pair has different colors. Print any producing a beautiful coloring, or 0 if impossible.
Input
The first line contains ; the second contains integers .
Output
Print any valid , or 0 if none exists.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
5
1 2 3 4 5
Output
2
Explanation
For , positions 2 and 4 are red while the others are blue, so adjacent positions always have different colors.