/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <stdio.h>
#include <time.h>
int main()
{
int a,b,c,d,e;
int n,t,x,y,q;
int covers[64][23];
int covered[64];
int uncovered;
int min_uncovered=63;
time_t start_t,end_t;
start_t=time(NULL);
for(a=0;a<64;a++){
covered[a]=n=0;
covers[a][n++]=a;
for(x=a%8+1,y=a/8+1;x<8 && y<8;x++,y++)covers[a][n++]=y*8+x;
for(x=a%8-1,y=a/8-1;x>=0 && y>=0;x--,y--)covers[a][n++]=y*8+x;
for(x=a%8+1,y=a/8-1;x<8 && y>=0;x++,y--)covers[a][n++]=y*8+x;
for(x=a%8-1,y=a/8+1;x>=0 && y<8;x--,y++)covers[a][n++]=y*8+x;
x=a%8;y=a/8;
if(y>0)
{
if(x>1)covers[a][n++]=a-10;
if(x<6)covers[a][n++]=a-6;
if(y>1)
{
if(x>0)covers[a][n++]=a-17;
if(x<7)covers[a][n++]=a-15;
}
}
if(y<7)
{
if(x>1)covers[a][n++]=a+6;
if(x<6)covers[a][n++]=a+10;
if(y<6)
{
if(x>0)covers[a][n++]=a+15;
if(x<7)covers[a][n++]=a+17;
}
}
covers[a][n]=-1;
if(n>t)t=n;
}
q=t=0;
for(a=0;a<60;a++){
for(n=0;covers[a][n]>=0;n++)covered[covers[a][n]]++;
for(b=a+1;b<61;b++){
for(n=0;covers[b][n]>=0;n++)covered[covers[b][n]]++;
for(c=b+1;c<62;c++){
for(n=0;covers[c][n]>=0;n++)covered[covers[c][n]]++;
for(d=c+1;d<63;d++){
for(n=0;covers[d][n]>=0;n++)covered[covers[d][n]]++;
for(e=d+1;e<64;e++){
t++;
for(n=0;covers[e][n]>=0;n++)covered[covers[e][n]]++;
for(n=uncovered=0;n<64;n++){
if(covered[n]==0)uncovered++;
}
if(uncovered==min_uncovered)q++;
else if(uncovered<min_uncovered){
min_uncovered=uncovered;
q=1;
}
for(n=0;covers[e][n]>=0;n++)covered[covers[e][n]]--;
}
for(n=0;covers[d][n]>=0;n++)covered[covers[d][n]]--;
}
for(n=0;covers[c][n]>=0;n++)covered[covers[c][n]]--;
}
for(n=0;covers[b][n]>=0;n++)covered[covers[b][n]]--;
}
for(n=0;covers[a][n]>=0;n++)covered[covers[a][n]]--;
}
end_t=time(NULL);
printf("positions checked: %d ",t);
printf("minimum uncovered: %d (%d positions) ",min_uncovered,q);
printf("elapsed time: %ld seconds",end_t-start_t);
return 0;
}