记录编号 142382 评测结果 AAAAAAAAAA
题目名称 [NOIP 2014PJ]螺旋矩阵 最终得分 100
用户昵称 Gravatar铁策 是否通过 通过
代码语言 Pascal 运行时间 0.002 s
提交时间 2014-12-08 13:00:12 内存使用 0.17 MiB
显示代码纯文本
program matrix;
var
n,i,j,k,l,m,ceng,qishi,bianj1,bianj3:longint;
begin
assign(input,'matrixc.in');
reset(input);
assign(output,'matrixc.out');
rewrite(output);
readln(n,i,j);
k:=i;
ceng:=i;
if j<ceng then ceng:=j;
if (n-i+1)<ceng then ceng:=n-i+1;
if (n-j+1)<ceng then ceng:=n-j+1;
for k:=1 to ceng-1 do inc(qishi,(n-k*2+1)*4);
qishi:=qishi+1;
if (n mod 2=1)and(ceng=n div 2+1) then begin
writeln(n*n);
close(input);
close(output);
halt;
end;
bianj1:=ceng;
bianj3:=n-ceng+1;
if (i=bianj1)and(j<bianj3) then writeln(qishi+(j-bianj1));
if (j=bianj3)and(i<bianj3) then writeln(qishi+(bianj3-bianj1)+(i-bianj1));
if (i=bianj3)and(j>bianj1) then writeln(qishi+(bianj3-bianj1)*2+(bianj3-j));
if (j=bianj1)and(i>bianj1) then writeln(qishi+(bianj3-bianj1)*3+(bianj3-i));
close(input);
close(output);
end.