CF449C.Jzzhu and Apples

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Jzzhu has picked n apples from his big apple tree. All the apples are numbered from 1 to n. Now he wants to sell them to an apple store.

Jzzhu will pack his apples into groups and then sell them. Each group must contain two apples, and the greatest common divisor of numbers of the apples in each group must be greater than 1. Of course, each apple can be part of at most one group.

Jzzhu wonders how to get the maximum possible number of groups. Can you help him?

Jzzhu 从他那棵大苹果树上摘下了 nn 个苹果。所有苹果均编号为 11 到 nn。现在他想把这些苹果卖给一家苹果店。

Jzzhu 将把苹果分组后再出售。每组必须恰好包含两个苹果,且组内两个苹果编号的最大公约数(GCD)必须大于 11。当然,每个苹果最多只能属于一个组。

Jzzhu 想知道如何获得尽可能多的组数。你能帮他解决这个问题吗?

输入格式

A single integer n (1 ≤ n ≤ 105), the number of the apples.

一个整数 nn(1 ≤ n ≤ 1051 \leq n \leq 10^5),表示苹果的数量。

输出格式

The first line must contain a single integer m, representing the maximum number of groups he can get. Each of the next m lines must contain two integers — the numbers of apples in the current group.

If there are several optimal answers you can print any of them.

第一行必须包含一个整数 mm,表示他最多能得到的组数。接下来的 mm 行每行必须包含两个整数——当前组中苹果的数量。

如果存在多个最优解,你可以输出其中任意一个。

输入输出样例

  • 输入#1

    6

    输出#1

    2
    6 3
    2 4
  • 输入#2

    9

    输出#2

    3
    9 3
    2 4
    6 8
  • 输入#3

    2

    输出#3

    0

输入解题思路,AI测评打分。不知道怎么写?

首页