凤
凤冠坡
Unregistered / Unconfirmed
GUEST, unregistred user!
Dos 下的算法:绝对最快!!
uses XCRT;
const Inter = 8;
Max = 16000;
var Number, M, I: LONGINT;
Magicgroup: array[1..14000] of LONGINT;
X, Y: BYTE;
function Getnumber(M: LONGINT): Boolean;
var I, N: LONGINT;
begin
N := ROUND(SQRT(M));
Getnumber := True;
I := 1;
repeat INC(I)
until (I = NUMBER) or (N < Magicgroup);
if N < Magicgroup then N := I;
begin N := I - 1
end;
for I := 1 to N do
if (M mod Magicgroup = 0) then
begin Getnumber := False
Exit
end
end;
begin CLOCKON;
Number := 1
X := GETX
Y := GETY;
Magicgroup[Number] := 2;
for I := 2 to Max do
begin if Getnumber(I) then
begin Number := Number + 1;
Magicgroup[Number] := I;
end
if I mod 1000 = 0 then
begin SETXY(X, Y)
Write(I: 6)
end;
end
BELL
WRITELN
CLOCKOFF
READLN;
for I := 1 to 100 do
begin {SETXY(10,1);} Write(Magicgroup: Inter);
end
Writeln(#13#10'总共:',
Number, #13#10'比率:',
Number / Max: 10: 7);
end.
uses XCRT;
const Inter = 8;
Max = 16000;
var Number, M, I: LONGINT;
Magicgroup: array[1..14000] of LONGINT;
X, Y: BYTE;
function Getnumber(M: LONGINT): Boolean;
var I, N: LONGINT;
begin
N := ROUND(SQRT(M));
Getnumber := True;
I := 1;
repeat INC(I)
until (I = NUMBER) or (N < Magicgroup);
if N < Magicgroup then N := I;
begin N := I - 1
end;
for I := 1 to N do
if (M mod Magicgroup = 0) then
begin Getnumber := False
Exit
end
end;
begin CLOCKON;
Number := 1
X := GETX
Y := GETY;
Magicgroup[Number] := 2;
for I := 2 to Max do
begin if Getnumber(I) then
begin Number := Number + 1;
Magicgroup[Number] := I;
end
if I mod 1000 = 0 then
begin SETXY(X, Y)
Write(I: 6)
end;
end
BELL
WRITELN
CLOCKOFF
READLN;
for I := 1 to 100 do
begin {SETXY(10,1);} Write(Magicgroup: Inter);
end
Writeln(#13#10'总共:',
Number, #13#10'比率:',
Number / Max: 10: 7);
end.