求教为什么60分,应该对的呀

P1618 三连击(升级版)

ArnoD @ 2015-10-05 15:11:46

var
  x,y,z:longint;
  a:array[1..9] of boolean;
  b:array[1..9] of longint;
procedure try(c:longint);
var
  i,yi,er,san:longint;
begin
  if c=10 then
  begin
    yi:=b[1]*100+b[2]*10+b[3];
    er:=b[4]*100+b[5]*10+b[6];
    san:=b[7]*100+b[8]*10+b[9];
    if (yi*y=er*x)and(yi*z=san*x)and(er*z=san*y) then
      writeln(yi,' ',er,' ',san);
    exit;
  end;
  for i:=1 to 9 do
    if not a[i] then
    begin
      a[i]:=true;
      b[c]:=i;
      try(c+1);
      a[i]:=false;
    end;
end;
begin
  x:=1;
  y:=2;
  z:=3; 
  try(1);
end.

by ArnoD @ 2015-10-05 15:30:53

这样反而40分了

var
  t:boolean; 
  x,y,z:longint;
  a:array[1..9] of boolean;
  b:array[1..9] of longint;
procedure try(c:longint);
var
  i,yi,er,san:longint;
begin
  if c=10 then
  begin
    yi:=b[1]*100+b[2]*10+b[3];
    er:=b[4]*100+b[5]*10+b[6];
    san:=b[7]*100+b[8]*10+b[9];
    if (yi*y=er*x)and(yi*z=san*x)and(er*z=san*y) then
      writeln(yi,' ',er,' ',san);
    exit;
    t:=true;
  end;
  for i:=1 to 9 do
    if not a[i] then
    begin
      a[i]:=true;
      b[c]:=i;
      try(c+1);
      a[i]:=false;
    end;
end;
begin
  readln(x,y,z);
  try(1);
  if not t then
    writeln('No!!!');
end.

by fl_334 @ 2015-10-05 15:31:23

(⊙o⊙)…你读入了吗。。。。。。。。。。。


by kczno1 @ 2015-10-07 10:12:31

你exit写在t:=true的前面,就不会执行t:=true了


by kczno1 @ 2015-10-07 10:16:57

而且t:=true应该放到if语句后面和writeln一起执行


|