为什么给0分啊
by LighTeers @ 2018-10-21 09:04:55
@[Andy0102](/space/show?uid=111816) 换行去掉试试
by wxy_god @ 2018-10-21 09:13:59
@[Andy0102](/space/show?uid=111816) 你那个100分提交记录是不是抄了题解……
by wxy_god @ 2018-10-21 09:15:09
@[我是一个垃圾](/space/show?uid=89396) 抄了,,,去了换行还是一片www
by LighTeers @ 2018-10-21 09:24:47
```
if(a[i]==0&&b[step+i]==0&&c[step-i+100]==0)
{
book[step][i]=1;
a[i]=1;
b[step+i]=1;
c[step-i+100]=1;
dfs(step+1);
book[step][i]=0;
a[i]=0;
b[step+i]=0;
c[step-i+100]=0;
}
```
好多+100是怎么回事
by wxy_god @ 2018-10-21 09:28:52
应该把+100改成+step
by wxy_god @ 2018-10-21 09:30:24
@[我是一个垃圾](/space/show?uid=89396) 我觉得不是+100的问题。。。
改了还是0分
by LighTeers @ 2018-10-21 09:50:02
仅供参考
****AC****
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstring>
using namespace std;
int a[16],p[16],q[31],r[31];int n,sum=0;
void print()
{
sum++;
if(sum<=3)
{
for(int i=1;i<=n;i++)
cout<<a[i]<<" ";
cout<<endl;
}
}
void dfs(int x)
{
int i;
for(i=1;i<=n;i++)
{
if(!p[i]&&!q[x+i]&&!r[x-i+n])
{
a[x]=i;
p[i]=1;
q[x+i]=1;
r[x-i+n]=1;
if(x==n) print();
else dfs(x+1);
p[i]=0;q[x+i]=0;r[x-i+n]=0;
}
}
}
int main()
{
//freopen("题目英文名.in","r",stdin);
// freopen("题目英文名.out","w",stdout);
cin>>n;
dfs(1);
cout<<sum;
//fclose(stdin);
//fclose(stdout);
return 0;
}
by shangdaoxuan @ 2018-11-02 17:16:43