```cpp
program interesting;
var i,j,k,m,n,x,y,s,l,r:longint;
a:array[0..330,0..330]of longint;
begin
readln(k);
for l:=1 to k do
begin
readln(n,x,y,r,m);
fillchar(a,sizeof(a),0);
if x=1 then
begin
if y=1 then
begin
s:=1;
for i:=1 to (n div r)+1 do
for j:=1 to r do
begin
a[i,j]:=s;
s:=s+1;
end;
end
else
begin
s:=1;
for i:=1 to (n div r)+1 do
for j:=1 to r do
begin
a[j,i]:=s;
s:=s+1;
end;
end;
end
else
begin
if y=1 then
begin
s:=2;i:=1;j:=1;a[1,1]:=1;
while s<=n do
begin
j:=j+2;
if j>r then
begin
i:=i+1;
j:=j mod r;
end;
a[i,j]:=s;
s:=s+1;
end;
end
else
begin
s:=2;i:=1;j:=1;a[1,1]:=1;
while s<=n do
begin
i:=i+2;
if i>r then
begin
j:=j+1;
i:=i mod r;
end;
a[i,j]:=s;
s:=s+1;
end;
end;
end;
for i:=1 to n do
for j:=1 to n do
if a[i,j]=m then
write(i,' ',j,' ');
end;
end.
这样都216,大佬救救我吧。
```
by 菜鸟ztc @ 2017-10-21 13:50:17
噢,这题貌似不能用数组啊
by 菜鸟ztc @ 2017-10-21 18:11:23
仍然过不了,有大佬帮帮蒟蒻吗?
by 菜鸟ztc @ 2017-10-22 22:35:58