讨论 / 求详细解法
wwww 2009-10-01 05:50:00
点我顶贴 收藏 删除
如题
#1 酷炫的狼@2008-10-21 05:40:00
回复 删除
用枚举!!!!!!!!!!
#2 Jollwish@2009-10-01 05:50:00
回复 删除
我这个玩的比较恶心。。小强啊

const ty:array[1..24,1..4]of integer=

((1,2,3,4),

(1,2,4,3),

(1,3,2,4),

(1,3,4,2),

(1,4,2,3),

(1,4,3,2),

(2,1,3,4),

(2,1,4,3),

(2,3,1,4),

(2,3,4,1),

(2,4,1,3),

(2,4,3,1),

(3,1,2,4),

(3,1,4,2),

(3,2,1,4),

(3,2,4,1),

(3,4,1,2),

(3,4,2,1),

(4,1,2,3),

(4,1,3,2),

(4,2,1,3),

(4,2,3,1),

(4,3,1,2),

(4,3,2,1)); //排列,我实在懒得弄括号了

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

c:char;

i,j,k,l1,l2,l3,l:integer;

t:real;

function change(c:char):integer;

begin

case c of

’A’:change:=1;

’J’:change:=11;

’Q’:change:=12;

’K’:change:=13;

else change:=ord(c)-ord(’0’);

end;

end;

function d(x,y:real):real;

begin

if y=0 then d:=100000

else d:=x /y;

end;

function op(i,l:integer;x,y:real):real;

begin

case i of

1:op:=x+y;

2:if l=1 then op:=x-y else op:=y-x;

3:op:=x*y;

4:if l=1 then op:=d(x,y) else op:=d(y,x);

end;

end;

begin

for i:=1 to 7 do

begin

read(c);

if odd(i) then a[(i+1) shr 1]:=change(c);

end;

for i:=1 to 4 do

for j:=1 to 4 do

for k:=1 to 4 do

for l:=1 to 24 do

for l1:=1 to 2 do

for l2:=1 to 2 do

for l3:=1 to 2 do

begin

t:=op(i,l1,a[ty[l,1]],a[ty[l,2]]);

t:=op(j,l2,t,a[ty[l,3]]);

t:=op(k,l3,t,a[ty[l,4]]);

if abs(t-24)<1e-8 then

begin

writeln(’yes’);

exit;

end;

end;

writeln(’no’);

end.

查看更多回复
提交回复