# 3101: N皇后

## 3101: N皇后

Time Limit: 10 Sec  Memory Limit: 128 MBSec  Special Judge

Submit: 88  Solved: 41

[Submit][Status][Discuss]

## Description

n*n的棋盘,在上面摆下n个皇后，使其两两间不能相互攻击…

4

2 4 1 3

## HINT

100%的数据3<n<1000000。输出任意一种合法解即可

## Source

 1 /**************************************************************
2     Problem: 3101
3     User: HansBug
4     Language: Pascal
5     Result: Accepted
6     Time:1832 ms
7     Memory:224 kb
8 ****************************************************************/
9
10 var
11    i,j,k,l,m,n:longint;
12 begin
14      case n mod 6 of
15           2,3:begin
16                    k:=n div 2;
17                    case (k mod 2)+(n mod 2)*2 of
18                         0:begin
19                                for i:=0 to (n-k) div 2 do writeln(k+i*2);
20                                for i:=0 to (k-4) div 2 do writeln(2+i*2);
21                                for i:=0 to (n-k-4) div 2 do writeln(k+3+i*2);
22                                for i:=0 to k div 2 do writeln(1+2*i);
23                         end;
24                         2:begin
25                                for i:=0 to (n-k-1) div 2 do writeln(k+i*2);
26                                for i:=0 to (k-4) div 2 do writeln(2+i*2);
27                                for i:=0 to (n-k-5) div 2 do writeln(k+3+i*2);
28                                for i:=0 to k div 2 do writeln(1+2*i);
29                                writeln(n);
30                         end;
31                         1:begin
32                                for i:=0 to (n-k-1) div 2 do writeln(k+i*2);
33                                for i:=0 to (k-3) div 2 do writeln(1+i*2);
34                                for i:=0 to (n-k-3) div 2 do writeln(k+3+i*2);
35                                for i:=0 to (k-1) div 2 do writeln(2+2*i);
36                         end;
37                         3:begin
38                                for i:=0 to (n-k-2) div 2 do writeln(k+i*2);
39                                for i:=0 to (k-3) div 2 do writeln(1+i*2);
40                                for i:=0 to (n-k-4) div 2 do writeln(k+3+i*2);
41                                for i:=0 to (k-1) div 2 do writeln(2+2*i);
42                                writeln(n);
43                         end;
44                    end;
45           end;
46           else begin
47                if odd(n) then
48                   begin
49                        for i:=1 to (n-1) div 2 do writeln(i*2);
50                        for i:=1 to (n+1) div 2 do writeln(i*2-1);
51                   end
52                else
53                    begin
54                         for i:=1 to n div 2 do writeln(i*2);
55                         for i:=1 to n div 2 do writeln(i*2-1);
56                    end;
57           end;
58      end;
60 end.

251 篇文章37 人订阅

0 条评论

## 相关文章

### 1257: [CQOI2007]余数之和sum

1257: [CQOI2007]余数之和sum Time Limit: 5 Sec  Memory Limit: 162 MB Submit: 2001  So...

29480

31220

### HOJ 1438 The Tower of Babylon（线性DP）

The Tower of Babylon My Tags Cancel - Seperate tags with commas. Source...

296110

### POJ3683 Priest John's Busiest Day(2-SAT)

Description John is the only priest in his town. September 1st is the John's bu...

34950

### BZOJ3560: DZY Loves Math V(欧拉函数)

\$\sum_{i_1 = 0}^{b_1} \sum_{i_2 = 0}^{b_2} \dots \sum_{i_n = 0}^{b_n} \phi( p^{\...

11960

47860

### BZOJ 1257: [CQOI2007]余数之和sum【神奇的做法，思维题】

1257: [CQOI2007]余数之和sum Time Limit: 5 Sec  Memory Limit: 162 MB Submit: 4474  So...

26540

10620

30350

### SDP（12）： MongoDB-Engine - Streaming

在akka-alpakka工具包里也提供了对MongoDB的stream-connector，能针对MongoDB数据库进行streaming操作。这个M...

493100