B
brt
Unregistered / Unconfirmed
GUEST, unregistred user!
以足彩13场全买310为例,共3的13次方1594323注,求能在20-30秒内列出全部1594323注结果的算法。(适用性要强)1000分等你呀,up有分
procedure TForm1.Button1Click(Sender: TObject);
var
s : TMemoryStream;
buf : PChar;
ca : array[0..2] of char;
t,v,i,j,bufp : DWORD;
begin
t := GetTickCount;
buf := AllocMem(1594323 * 15);
ca[0] := '0';
ca[1] := '1';
ca[2] := '3';
bufp := 14;
for i := 0 to 1594323 - 1do
begin
buf[bufp] := #10;
dec(bufp);
buf[bufp] := #13;
dec(bufp);
v := i;
for j := 0 to 12do
begin
buf[bufp] := ca[v mod 3];
v := v div 3;
dec(bufp);
end;
bufp := bufp + 29;
end;
s := TMemoryStream.Create;
s.Write(buf^,1594323 * 15);
s.SaveToFile('c:/rst.txt');
s.Free;
FreeMem(buf);
showmessage('cost:' + IntToStr(GetTickCount - t) + 'ms');
end;