guys,a little help here…i have succesfully solved the problem but it is showing presentation error…
does anybody know the output format of this problem…
here is my code :
#include<cstdio>
#include<iostream>
#include<vector>
#include<bitset>
#include<cstring>
using namespace std;
int a[100],n,line=0,num;
bool vis[100];
bool isprime[]={0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0};
void dfs(int k,int x)
{
int i;
if(x==n)
{
if(isprime[a[1]+a[x]]||(n==1))
{
for(i=1;i<=n;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
}
return;
}
else
{
vis[k]=true;
for(i=2;i<=n;i++)
{
if(!vis[i] && isprime[k+i])
{
a[x+1]=i;
dfs(i,x+1);
}
}
vis[k]=false;
}
}
int main()
{
num=0;
while(scanf("%d",&n)==1 && n>0)
{
memset(vis,0,17*sizeof(bool));
++num;
if(num>1)
cout<<endl;
a[1]=1;
cout<<"Case"<<" "<<num<<":"<<endl;
dfs(1,1);
}
return 0;
}