#SP0000236. Ghép cặp táo của Jzzhu (Jzzhu and Apples)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Ghép cặp táo của Jzzhu (Jzzhu and Apples)
Jzzhu and Apples
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Jzzhu has apples numbered through . He wants to divide some of them into groups of exactly two apples. Apples and may be paired only when , meaning their numbers share a prime divisor.
Each apple may belong to at most one group; unpaired apples are permitted.
Find the maximum number of groups and output any pairing achieving that maximum. If several optimal pairings exist, you may output any one of them.
Input
The only line contains an integer .
Output
Print , the maximum number of groups, on the first line. Each of the following lines contains two apple indices in a group. Each number in may appear at most once, and must hold.
Subtasks
-
Subtask 1 (20 points): .
-
Subtask 2 (30 points): .
-
Subtask 3 (50 points): .
Examples
Input
6
Output
2
6 3
2 4
Explanation
For , the apples are numbered . Pair is valid as ; pair is valid as . The four numbers are distinct. Of the remaining apples and , apple cannot be paired with any number, and has no other multiple of up to . Thus at most two pairs are possible, and the sample attains this maximum.