#Q203. 「一本通 6.2 练习 4」Sherlock and His Girlfriend

    ID: 2285 Type: Default 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>数论Codeforces埃氏筛及欧拉筛一本通提高

「一本通 6.2 练习 4」Sherlock and His Girlfriend

Description

Original problem from: Codeforces Round #400 B.

Sherlock has a new girlfriend (which is very unlike him!). Valentine's Day is approaching, and he wants to give her some jewelry as a gift.

He bought nn pieces of jewelry. The value of the ii-th piece is i+1i+1. That is, the values of the jewelry are 2,3,4,,n+12, 3, 4, \cdots, n+1.

Watson challenges Sherlock to color these pieces such that when the value of one piece is a prime factor of another, the two pieces must have different colors. Additionally, Watson requires him to minimize the number of colors used.

Please help Sherlock complete this simple task.

Input Format

A single integer nn, representing the number of jewelry pieces.

Output Format

The first line should contain an integer kk, indicating the minimum number of colors used.
The second line should contain nn integers, representing the colors assigned to the 11-st to the nn-th piece of jewelry. If there are multiple possible solutions, output any one of them.

Sample 1

3

2
1 1 2

Sample 2

Since 22 is a prime factor of 44, the first and third pieces of jewelry must have different colors.

4

2
2 1 1 2

Data Range and Hints

For all data, 1n1051\le n\le 10^5.