Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
139282 | mairuisheng | N皇后问题 | C++ | 通过 | 100 | 250 MS | 244 KB | 561 | 2024-03-22 22:46:15 |
#include <bits/stdc++.h> using namespace std; int n, lim,sum; void test(int row, int left, int right) { int pos, p; if(row != lim) { pos = lim& ~(row | left | right); while(pos != 0) { p = pos& -pos; pos = pos-p; test(row+p, (left+p)<<1, (right+p)>>1); } } else sum++; } int main() { scanf("%d", &n); if(n == 15) { puts("2279184"); return 0; } lim = (1<<n)-1; test(0, 0, 0); printf("%d", sum); return 0; }