讨论 / 只得了50分求神牛改程序~~~
58长的像SB 2010-10-31 05:10:00
点我顶贴 收藏 删除
program yui(input,output);

var

i,j,c:integer;

s:string;

a:array[1..4] of integer;

b:array[1..4] of boolean;

procedure young(i:integer);

begin

if i=24 then begin write('yes');halt;end;

if i>24 then exit;

if (b[1]=true)and(b[2]=true)and(b[3]=true)and(b[4]=true) then exit;

for j:=1 to 4 do

if b[j]=false then begin b[j]:=true;young(i*a[j]);

young(i+a[j]);

young(abs(i-a[j]));

if i mod a[j]=0 then young(i div a[j]);

if (a[j] mod i=0)and(i<>0) then young(a[j] div i);

b[j]:=false;

end;

end;

begin

readln(s);

for i:=1 to 4 do

begin if(s[i*2-1]='1')and(s[i*2]='0') then begin delete(s,i*2,1);a[i]:=10;break;end;

if (s[i*2-1]<>'A')and(s[i*2-1]<>'J')and(s[i*2-1]<>'Q')and(s[i*2-1]<>'K') then

val(copy(s,i*2-1,1),a[i],c) else begin

if s[i*2-1]='A' then a[i]:=1;

if s[i*2-1]='J' then a[i]:=11;

if s[i*2-1]='Q' then a[i]:=12;

if s[i*2-1]='K' then a[i]:=13;

end;

end;

fillchar(b,sizeof(b),false);

for i:=1 to 4 do

begin b[i]:=true;young(a[i]);b[i]:=false; end;

write('no');

end.

查看更多回复
提交回复