PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000073. Ehab và bài toán tô màu đặc biệt (Ehab and a Special Coloring Problem)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ehab và bài toán tô màu đặc biệt (Ehab and a Special Coloring Problem)
Ehab and a Special Coloring Problem
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Assign a positive integer color to each integer from through . Whenever two integers are coprime, meaning , their colors must differ: . Among valid assignments, minimize the largest color . You may print any assignment attaining this minimum.
Input
One line contains the integer .
Output
Print positive integer colors , separated by spaces; the maximum color must be as small as possible.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
4
Output
1 2 1
Explanation
Assign color to , color to , and color to , producing 1 2 1. Values and may share a color since ; pairs involving are coprime and must differ. One color is impossible because , so a maximum color of is optimal.