Hex(abcdefg)=a6+ b6+ c6+ d6+ e6+ f6+ g6
有什么最快的方法
用DELPHI写了一个:
function cacl(a: integer): integer; //求六次方的函数
var
b:integer;
begin
asm
xor eax,eax
xor esi,esi
mov eax,a
mov ecx,eax
mov esi,$6
@:
imul eax,ecx
dec esi
jne @
mov b,eax
end;
Result := b;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
s,i:integer;
c:string;
d:string;
begin
for i := 1000000 to 9999999 do
begin
d:=inttostr(i);
s1:=cacl(strtoint(midstr(d,1,1)));
s2:=cacl(strtoint(midstr(d,2,1)));
s3:=cacl(strtoint(midstr(d,3,1)));
s4:=cacl(strtoint(midstr(d,4,1)));
s5:=cacl(strtoint(midstr(d,5,1)));
s6:=cacl(strtoint(midstr(d,6,1)));
s7:=cacl(strtoint(midstr(d,7,1)));
s:=s1+s2+s3+s4+s5+s6+s7;
if s=i then break ;
edit1.Text:=inttostr(i);
end;
end;
end.
不知道行不行,但是计算奇慢.
[此贴子已经被作者于2006-8-29 11:22:15编辑过]