回分類題庫
d216: CP2 Lab Exercise: NQueen Problem
出處:

Difficulity : N/A
Accepted : 157 Times | Submit :233 Times | Clicks : 1713
Accepted : 43 Users | Submit : 45 Users | Accepted rate : 96%
Time Limit :15000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2011-03-16 15:48

Content :

In chess, Queen can move along vertical, horizontal and diagonal line and kill others on her path.

There is an N x N chess board and N queens, you are asked to write a recursive program to find the number of the solutions that all the queens won't kill each other.

 You are asked to write a recursive program by editing this code
~g9803/nqueen_ex.c

Object: Practice passing 2D array and recursion

Submit with your account.
 

Input :

An integer N, where 3 < N < 14

Output :

An integer K, which means the number of the solutions.

Sample Input :

4
5

Sample Output :

2
10

Hint :


  

Author :


  Solve it!   Status Forum (0)

C++
C
JAVA
49497. CC501 (6 ms , 216KB)
30560. nothinglo (2 ms , 158KB)
30491. cp99703032 (2 ms , 200KB)
30496. nothinglo (4 ms , 156KB)
30557. nothinglo (6 ms , 160KB)
30553. nothinglo (6 ms , 154KB)
54315. nwgs524513cja (114 ms , 180KB)
87963. nwgs524513cja ( 2 s , 2294KB)
54299. nwgs524513cja ( 2 s , 2252KB)
54297. nwgs524513cja ( 2.3 s , 2306KB)

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡