CF1038B.Non-Coprime Partition
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Find out if it is possible to partition the first n positive integers into two non-empty disjoint sets S1 and S2 such that:
gcd(sum(S1),sum(S2))>1
Here sum(S) denotes the sum of all elements present in set S and gcd means thegreatest common divisor.
Every integer number from 1 to n should be present in exactly one of S1 or S2.
判断是否可以将前 n 个正整数划分为两个非空、不相交的集合 S1 和 S2,使得:
gcd(sum(S1),sum(S2))>1
其中 sum(S) 表示集合 S 中所有元素的和,gcd 表示最大公约数。
从 1 到 n 的每个整数必须恰好出现在 S1 或 S2 中的一个集合里。
输入格式
The only line of the input contains a single integer n (1≤n≤45000)
输入仅包含一行,其中有一个整数 n(1≤n≤45000)
输出格式
If such partition doesn't exist, print "No" (quotes for clarity).
Otherwise, print "Yes" (quotes for clarity), followed by two lines, describing S1 and S2 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”(引号仅用于清晰显示),随后输出两行,分别描述集合 S1 和 S2。
每个集合的描述以该集合的大小开头,后跟该集合的元素(顺序任意)。每个集合必须非空。
如果存在多种可能的划分,输出任意一种即可。
输入输出样例
输入#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 2 and 4 respectively. The gcd(2,4)=2>1, hence that is one of the possible answers.
在第一个例子中,无法将单个数字划分为两个非空集合,因此答案为“No”。
在第二个例子中,这两个集合的和分别为 2 和 4。gcd(2,4)=2>1,因此这是一种可能的答案。
输入解题思路,AI测评打分。不知道怎么写?