RE求助
查看原帖
RE求助
330451
帅皮的瓜粉楼主2020/6/6 19:59
#include<bits/stdc++.h>
using namespace std;
int a[20]={0,1},n,b[100],flag;
bool c[10000]={0,1};
void dfs(int x,int y)
{
	if(x==n+1&&b[a[n]+a[1]])
	{
		for(int i=1;i<n;i++)cout<<a[i];
		cout<<a[n]<<endl;
	}
	if(x==n+1)return ;
	for(int i=y;i<=n;i+=2)
	{
		if(!c[i]&&b[i+a[x-1]])
		{
			a[x]=i;
			c[i]=1;
			dfs(x+1,y^3);
			c[i]=0;
		} 
	}
}
int main()
{
	int flag=0;
	b[2]=b[3]=b[5]=b[7]=b[11]=b[13]=b[17]=b[19]=b[23]=b[29]=b[31]=1;
	while(scanf("%d",&n)!=EOF)
	{
		if(flag)printf("\n");
		cout<<"Case :"<<flag;
		flag++;
		dfs(2,2);
	}
	return 0;
}

https://www.luogu.com.cn/record/34192995

2020/6/6 19:59
加载中...