5 楼
sd5774188 [专家分:260] 发布于 2005-07-25 21:16:00
发个无敌点的程序(过了的)
program p1025(input,output);
var t,n,i:integer;
begin
read(t);
for i:=1 to t do
begin
read(n);
case n of
1:writeln(1);
2:begin
writeln(1,' ',2);
writeln(4,' ',3);
end;
3:writeln('NO');
4:begin
writeln(1,' ',2,' ',11,' ',12);
writeln(4,' ',9,' ',8,' ',5);
writeln(7,' ',10,' ',3,' ',14);
writeln(6,' ',13,' ',16,' ',15);
end;
5:begin
writeln(1,' ',2,' ',3,' ',4,' ',7);
writeln(6,' ',5,' ',8,' ',15,' ',22);
writeln(25,' ',18,' ',23,' ',14,' ',9);
writeln(16,' ',13,' ',24,' ',17,' ',20);
writeln(21,' ',10,' ',19,' ',12,' ',11);
end;
6:begin
writeln(1,' ',2,' ',3,' ',4,' ',7,' ',6);
writeln(10,' ',21,' ',16,' ',13,' ',24,' ',5);
writeln(19,' ',22,' ',25,' ',18,' ',23,' ',14);
writeln(12,' ',31,' ',36,' ',35,' ',8,' ',15);
writeln(29,' ',30,' ',17,' ',26,' ',33,' ',28);
writeln(32,' ',11,' ',20,' ',27,' ',34,' ',9);
end;
7:begin
writeln(1,' ',2,' ',3,' ',4,' ',7,' ',6,' ',5);
writeln(10,' ',9,' ',8,' ',15,' ',16,' ',13,' ',18);
writeln(19,' ',22,' ',21,' ',46,' ',37,' ',24,' ',23);
writeln(12,' ',49,' ',40,' ',43,' ',30,' ',29,' ',14);
writeln(35,' ',48,' ',31,' ',36,' ',17,' ',44,' ',39);
writeln(38,' ',41,' ',42,' ',11,' ',26,' ',45,' ',28);
writeln(33,' ',20,' ',47,' ',32,' ',27,' ',34,' ',25);
end;
8:begin
writeln(1,' ',2,' ',3,' ',4,' ',7,' ',6,' ',5,' ',8);
writeln(10,' ',9,' ',14,' ',15,' ',16,' ',13,' ',18,' ',11);
writeln(19,' ',22,' ',39,' ',28,' ',25,' ',34,' ',49,' ',12);
writeln(24,' ',37,' ',64,' ',33,' ',46,' ',55,' ',54,' ',17);
writeln(23,' ',60,' ',43,' ',40,' ',61,' ',42,' ',29,' ',44);
writeln(56,' ',41,' ',30,' ',31,' ',36,' ',47,' ',32,' ',27);
writeln(57,' ',26,' ',53,' ',48,' ',35,' ',62,' ',21,' ',52);
writeln(50,' ',63,' ',20,' ',59,' ',38,' ',45,' ',58,' ',51);
end;
9:begin
writeln(1,' ',2,' ',3,' ',4,' ',7,' ',6,' ',5,' ',8,' ',9);
writeln(10,' ',21,' ',16,' ',13,' ',24,' ',17,' ',12,' ',11,' ',20);
writeln(19,' ',22,' ',15,' ',28,' ',43,' ',30,' ',29,' ',18,' ',23);
writeln(34,' ',25,' ',46,' ',33,' ',40,' ',31,' ',42,' ',41,' ',38);
writeln(27,' ',76,' ',37,' ',64,' ',49,' ',48,' ',59,' ',68,' ',69);
writeln(52,' ',61,' ',36,' ',67,' ',60,' ',53,' ',44,' ',39,' ',70);
writeln(79,' ',78,' ',35,' ',72,' ',77,' ',74,' ',63,' ',50,' ',81);
writeln(58,' ',73,' ',66,' ',65,' ',62,' ',75,' ',26,' ',57,' ',32);
writeln(55,' ',54,' ',47,' ',14,' ',45,' ',56,' ',71,' ',80,' ',51);
end;
10:begin
writeln(1,' ',2,' ',3,' ',4,' ',7,' ',6,' ',5,' ',8,' ',9,' ',10);
writeln(12,' ',11,' ',20,' ',27,' ',16,' ',13,' ',18,' ',23,' ',14,' ',33);
writeln(17,' ',26,' ',21,' ',32,' ',15,' ',28,' ',19,' ',24,' ',29,' ',38);
writeln(30,' ',41,' ',62,' ',35,' ',44,' ',39,' ',22,' ',37,' ',42,' ',59);
writeln(31,' ',48,' ',65,' ',36,' ',53,' ',50,' ',51,' ',46,' ',25,' ',54);
writeln(40,' ',61,' ',66,' ',43,' ',60,' ',47,' ',56,' ',57,' ',82,' ',49);
writeln(63,' ',76,' ',73,' ',58,' ',91,' ',90,' ',83,' ',74,' ',75,' ',88);
writeln(86,' ',81,' ',100,' ',79,' ',72,' ',77,' ',80,' ',99,' ',52,' ',85);
writeln(93,' ',70,' ',97,' ',34,' ',67,' ',96,' ',71,' ',68,' ',45,' ',64);
writeln(98,' ',69,' ',94,' ',55,' ',84,' ',95,' ',78,' ',89,' ',92,' ',87);
end;
end;
end;
end.