跳到正文

个人记录

有没有大佬说一下为什么输出是1

zsz808约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月20日
更新
2025年12月20日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include <iostream>
using namespace std;
int ans,x[5][5],y[5][5],co[5][5],r,c,b;
void dfs(int a)
{
	if(a>16)
	{
		ans++;
		return;
	}
	r=(a-1)/4+1;
	c=(a-1)%4+1;
	b=(r-1)/2*2+(c-1)/2+1;
	for(int i=1;i<=4;i++)
	{
		if(x[r][i]==0&&y[c][i]==0&&co[b][i]==0)
		{
			x[r][i]=y[c][i]=co[b][i]=1;
			dfs(a+1);
			x[r][i]=y[c][i]=co[b][i]=0;
		}
	}
}
int main()
{
	dfs(1);
	cout<<ans;
	return 0;
}
原文