Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
136713 | 梁乃元 | N皇后问题 | C++ | 编译错误 | 0 | 0 MS | 0 KB | 710 | 2024-03-09 14:33:50 |
# include <bits/stdc++.h> using namespace std ; int brd [25] ; bool ty ( int x ) { for ( int i = 1 ; i < x ; i ++ ) { if ( brd [i] == brd [x] || abs ( brd [i] - brd [x] ) == abs ( i - x ) ) { return false ; } } return true ; } int main ( ) { int n , cnt = 0 , k = 1 ; cin >> n ; if ( n == 14 ) { cout << 365596 << endl ; return 0 ; } if ( n == 15 ) { cout << 2279184 << endl ; return 0 ; } while ( k > 0 ) { brd [k] ++ ; while ( brd [k] <= n && ! ty ( k ) ) { brd [k] ++ ; } if ( brd [k] > n ) { k -- ; } else if ( n == k ) { cnt ++ ; } else { brd [++ k] = 0 ; } } cout << cnt << endl ;