program t74;
var
b,c,d:integer;
a:array[1..4]of integer;
s,t:char;
procedure sou(o,p:integer);
var
i,j,k:integer;
begin
if o=24 then begin write('yes');halt;end;
if p=5 then exit;
sou(o+a[p],p+1);
sou(o-a[p],p+1);
sou(o*a[p],p+1);
if (a[p]<>0)and(o mod a[p]=0) then sou(o div a[p],p+1);
end;
begin
for b:=1 to 4 do
begin
read(s); if b<>4 then read(t);
if s='1' then begin read(t);a[b]:=10 end else
case s of
'A':a[b]:=1;
'2':a[b]:=2;
'3':a[b]:=3;
'4':a[b]:=4;
'5':a[b]:=5;
'6':a[b]:=6;
'7':a[b]:=7;
'8':a[b]:=8;
'9':a[b]:=9;
'J':a[b]:=11;
'Q':a[b]:=12;
'K':a[b]:=13;
end;
end;
c:=0; d:=1;
sou(c,d);
write('no');
end.
sou(a[p]-o,p+1);
if (o<>0) then sou(o / a[p],p+1);
照你说得改了
分更低了
就剩50了
program t74;
var
b,c,d:integer;
a:array[1..4]of integer;
s,t:char;
procedure sou(o,p:integer);
var
i,j,k:integer;
begin
if o=24 then begin write('yes');halt;end;
if p=5 then exit;
sou(a[p]-o,p+1);
sou(o+a[p],p+1);
sou(o-a[p],p+1);
sou(o*a[p],p+1);
if (o<>0)and(o mod a[p]=0) then sou(o div a[p],p+1);
end;
begin
for b:=1 to 4 do
begin
read(s); if b<>4 then read(t);
if s='1' then begin read(t);a[b]:=10 end else
case s of
'A':a[b]:=1;
'2':a[b]:=2;
'3':a[b]:=3;
'4':a[b]:=4;
'5':a[b]:=5;
'6':a[b]:=6;
'7':a[b]:=7;
'8':a[b]:=8;
'9':a[b]:=9;
'J':a[b]:=11;
'Q':a[b]:=12;
'K':a[b]:=13;
end;
end;
c:=0; d:=1;
sou(c,d);
write('no');
end.