内容目录
线性筛素数……
Program P3006; const maxn=1000000; var prime:array[1..maxn] of boolean; p:array[1..maxn] of longint; t:longint; a,d,n:longint; Procedure primeing; var i,j:longint; begin fillchar(prime,sizeof(prime),false); t:=0; prime[1]:=true; for i:=2 to maxn do begin if not(prime[i]) then begin inc(t); p[t]:=i; end; for j:=1 to t do begin if p[j]*i>maxn then break; prime[p[j]*i]:=true; if i mod p[j]=0 then break; end; end; end; begin primeing; readln(a,d,n); while (a+d+n>0) do begin while (n>0) do begin if not(prime[a]) then dec(n); inc(a,d); end; writeln(a-d); readln(a,d,n); end; end.