# uva 524 prime ring problem

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;
}``````

whats the problem mine is also giving presentation error

This issue can be fathomed effortlessly utilizing recursive back following. Make a procedure for checking whether a number is prime. Have a recursive strategy that monitors the present digit, and check values 2 to n to check whether you can put them in the exhibit given that the past number and the new esteem whole to a prime number.

Write my paper for cheap

can u provide the ques link!!!

well i just figured out the ans…so it won’t be necessary but you can still have a look at the question.