PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000050. Sherlock và bạn gái (Sherlock and His Girlfriend)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Sherlock và bạn gái (Sherlock and His Girlfriend)
Sherlock and His Girlfriend
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Sherlock has pieces of jewelry indexed from to , with respective prices . Color them so that two pieces use different colors whenever the price of one is a prime divisor of the price of the other. Minimize the number of distinct colors. Any optimal coloring is acceptable.
Input
One line containing the integer .
Output
The first line contains the minimum number of colors . The second line has exactly integers , with , where is the color for price .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
3
Output
2
1 1 2
Explanation
There are three prices, . Since is a prime divisor of , those prices must have different colors. Assign color to prices and color to price . One color is impossible, so two colors are optimal.