CF1038B.Non-Coprime Partition

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Find out if it is possible to partition the first nn positive integers into two non-empty disjoint sets S1S_1 and S2S_2 such that:

gcd(sum(S1),sum(S2))>1\mathrm{gcd}(\mathrm{sum}(S_1), \mathrm{sum}(S_2)) \gt 1

Here sum(S)\mathrm{sum}(S) denotes the sum of all elements present in set SS and gcd\mathrm{gcd} means thegreatest common divisor.

Every integer number from 11 to nn should be present in exactly one of S1S_1 or S2S_2.

判断是否可以将前 nn 个正整数划分为两个非空、不相交的集合 S1S_1 和 S2S_2,使得:

gcd(sum(S1),sum(S2))>1\mathrm{gcd}(\mathrm{sum}(S_1), \mathrm{sum}(S_2)) \gt 1

其中 sum(S)\mathrm{sum}(S) 表示集合 SS 中所有元素的和,gcd\mathrm{gcd} 表示最大公约数。

从 11 到 nn 的每个整数必须恰好出现在 S1S_1 或 S2S_2 中的一个集合里。

输入格式

The only line of the input contains a single integer nn (1≤n≤45 0001 \le n \le 45\,000)

输入仅包含一行,其中有一个整数 nn(1≤n≤45 0001 \le n \le 45\,000)

输出格式

If such partition doesn't exist, print "No" (quotes for clarity).

Otherwise, print "Yes" (quotes for clarity), followed by two lines, describing S1S_1 and S2S_2 respectively.

Each set description starts with the set size, followed by the elements of the set in any order. Each set must be non-empty.

If there are multiple possible partitions — print any of them.

如果不存在这样的划分,输出“No”(引号仅用于清晰显示)。

否则,输出“Yes”(引号仅用于清晰显示),随后输出两行,分别描述集合 S1S_1 和 S2S_2。

每个集合的描述以该集合的大小开头,后跟该集合的元素(顺序任意)。每个集合必须非空。

如果存在多种可能的划分,输出任意一种即可。

输入输出样例

  • 输入#1

    1

    输出#1

    No
  • 输入#2

    3

    输出#2

    Yes
    1 2
    2 1 3

说明/提示

In the first example, there is no way to partition a single number into two non-empty sets, hence the answer is "No".

In the second example, the sums of the sets are 22 and 44 respectively. The gcd(2,4)=2>1\mathrm{gcd}(2, 4) = 2 \gt 1, hence that is one of the possible answers.

在第一个例子中,无法将单个数字划分为两个非空集合,因此答案为“No”。

在第二个例子中,这两个集合的和分别为 22 和 44。gcd(2,4)=2>1\mathrm{gcd}(2, 4) = 2 \gt 1,因此这是一种可能的答案。

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

首页