主题:马栏过河卒的问题(请问camp和longint有什么区别?)
program ma(input,output);
const
a:array[1..8] of longint=(1, 2,-1,-2, 1, 2,-1,-2);
b:array[1..8] of longint=(2,1,-2,-1,-2,-1, 2, 1);
var
g:array[0..20,0..20] of 0..1;
f:array[0..20,0..20] of [color=00FF00]comp;{why use comp or real,but not longint}[/color]
i,j,x,y:longint;
procedure readit;
var
k:longint;
begin
readln(i,j,x,y);
fillchar(g,sizeof(g),0);
g[x,y]:=1;
for k:=1 to 8 do
if (x+a[k]>=0) and (x+a[k]<=i) and
(y+b[k]>=0) and (y+b[k]<=j)
then g[x+a[k],y+b[k]]:=1;
end;
procedure doit;
var
k,m,n,l:longint;
begin
f[0,0]:=1;
for k:=1 to i do
if g[k,0]=0 then f[k,0]:=f[k-1,0];
for l:=1 to j do
if g[0,l]=0 then f[0,l]:=f[0,l-1];
for m:=1 to i do
for n:=1 to j do
if g[m,n]=0 then f[m,n]:=f[m-1,n] +f[m,n-1];
end;
begin
readit;
doit;
writeln(f[i,j[color=00FF00]]:0:0);[/color]
end.
程序第七行,我用longint就一直失败(部分数据),改为camp或real的话,就可以拉,我很奇怪,这是为什么????(可以试一下正确答案in:19 19 1 0 out:2203961430,但答案错误,为负数)
[color=FF0000][/color]
const
a:array[1..8] of longint=(1, 2,-1,-2, 1, 2,-1,-2);
b:array[1..8] of longint=(2,1,-2,-1,-2,-1, 2, 1);
var
g:array[0..20,0..20] of 0..1;
f:array[0..20,0..20] of [color=00FF00]comp;{why use comp or real,but not longint}[/color]
i,j,x,y:longint;
procedure readit;
var
k:longint;
begin
readln(i,j,x,y);
fillchar(g,sizeof(g),0);
g[x,y]:=1;
for k:=1 to 8 do
if (x+a[k]>=0) and (x+a[k]<=i) and
(y+b[k]>=0) and (y+b[k]<=j)
then g[x+a[k],y+b[k]]:=1;
end;
procedure doit;
var
k,m,n,l:longint;
begin
f[0,0]:=1;
for k:=1 to i do
if g[k,0]=0 then f[k,0]:=f[k-1,0];
for l:=1 to j do
if g[0,l]=0 then f[0,l]:=f[0,l-1];
for m:=1 to i do
for n:=1 to j do
if g[m,n]=0 then f[m,n]:=f[m-1,n] +f[m,n-1];
end;
begin
readit;
doit;
writeln(f[i,j[color=00FF00]]:0:0);[/color]
end.
程序第七行,我用longint就一直失败(部分数据),改为camp或real的话,就可以拉,我很奇怪,这是为什么????(可以试一下正确答案in:19 19 1 0 out:2203961430,但答案错误,为负数)
[color=FF0000][/color]