#SP0000072. Tô màu các hợp số (Composite Coloring)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tô màu các hợp số (Composite Coloring)
Composite Coloring
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given composite integers . Choose colors () and assign each position a color from through . Every color must be used at least once. Whenever two positions have the same color, the greatest common divisor of their values must be greater than . You need not minimize the number of colors; any valid coloring using at most colors is accepted.
Input
The first line contains . The second line contains exactly composite integers in order.
Output
Print on the first line and space-separated colors on the second. Every color must appear, and every pair of values assigned the same color must have GCD greater than .
Subtasks
- Subtask 1 (20 points): ; for every ; all are composite.
- Subtask 2 (30 points): ; for every ; all are composite.
- Subtask 3 (50 points): ; for every ; all are composite.
Examples
Input
3
6 10 15
Output
1
1 1 1
Explanation
The composite values are . We can use one color, assigning , because , , and , all greater than . Hence printing 1 and 1 1 1 is valid. Other valid colorings are also accepted.