卡布列克常数(pascal)pascal的啊!不过不急用.
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/28 19:33:54
卡布列克常数(pascal)pascal的啊!不过不急用.
卡布列克常数(pascal)
pascal的啊!不过不急用.
卡布列克常数(pascal)pascal的啊!不过不急用.
program asdf;
var
a:array[1000..9998] of integer;
b:array[1..24] of integer;
i,j,k,l,w,x,y,z,w1,x1,y1,z1,xx,yy,ii:Integer;
begin
for i:=1000 to 9998 do
begin
ii:=i;
w:=ii div 1000;
x:=ii div 100-w*10;
y:=ii div 10-w*100-x*10;
z:=ii mod 10;
if not((w=x)and(x=y)and (y=z)) then begin
yy:=1;
for j:=1 to 7 do
for w1:=1 to 4 do
for x1:=1 to 4 do
for y1:=1 to 4 do
for z1:=1 to 4 do
begin
if (w1+x1+y1+z1=1+2+3+4)and(w1*x1*y1*z1=1*2*3*4) then begin
for k:=1 to 4 do begin
xx:=1;
case k of
1:for l:=1 to w1 do begin xx:=xx*10; b[yy]:=b[yy]+w1; end;
2:for l:=1 to x1 do begin xx:=xx*10; b[yy]:=b[yy]+x1; end;
3:for l:=1 to y1 do begin xx:=xx*10; b[yy]:=b[yy]+y1; end;
4:for l:=1 to z1 do begin xx:=xx*10; b[yy]:=b[yy]+z1; inc(yy); end;
end;
end;
end;
end;
for k:=1 to 24 do
for l:=1 to k do
if b[k]>b[l] then begin b[k]:=b[l]+b[k]; b[l]:=b[k]-b[l]; b[k]:=b[k]-b[l]; end;
ii:=abs(b[k]-b[l]);
if ii=6174 then begin a[i]:=j; break; end;
end;
end;
end;
for i:=1000 to 9998 do
writeln(i,':',a[i]);
readln;
end.