B Non-Coprime Partition(构造+思维)

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

.

Input

The only line of the input contains a single integer n

(1≤n≤45000

)

Output

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.

Examples

Input

Copy

1

Output

Copy

No

Input

Copy

3

Output

Copy

Yes
1 2
2 1 3 

Note

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.

题意:给一个数n,将1到n之间的整数,分成两组,每组的和分别为sum1,sum2,如果gcd(sum1,sum2)>1,则输出每组的大小

和含有的元素,否则输出No

#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	if(n<=2) printf("No\n");
	else{
		printf("Yes\n");
		int a=n/2;
		int b=a;
		if(n%2) b=a+1;
		printf("%d",a);
		for(int i=2;i<=n;i+=2)
			printf(" %d",i);
		puts("");
		printf("%d",b);
		for(int i=1;i<=n;i+=2)
			printf(" %d",i);
		puts("");
	}
	return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值