#include<stdio.h>
int n;
int p[1000][1000];
int sum,half,count,k;
void dfs(int k){
if(k>n){
if(count==half){
sum++;
}
return ;
}
else{
for(int i=0;i<=1;i++){
p[1][k]=i;
count+=i;
for(int j=2;j<=k;j++){
p[j][k-j+1]=p[j-1][k-j+1]^p[j-1][k-j+2];
count+=p[j][k-j+1];
}
if(count<=half&&(k+1)*k/2-count<=half){
dfs(k+1);
}
for(int j=2;j<=k;j++){
count-=p[j][k-j+1];
}
count-=i;
}
}
}
int main(){
scanf("%d",&n);
half=n*(n+1)/4;
dfs(1);
printf("%d",sum);
}
08-10
715
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-05
376
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-10