Cod sursa(job #514243)

Utilizator vendettaSalajan Razvan vendetta Data 18 decembrie 2010 08:45:59
Problema Ciurul lui Eratosthenes Scor 0
Compilator fpc Status done
Runda Arhiva educationala Marime 0.79 kb
const f='ciur.in';g='ciur.out';
    nmax=100000000;
var
    v:array[1..nmax] of integer;
    n,i,j,cate:longint;
begin
    assign(input,f);reset(input);
    assign(output,g);rewrite(output);
    read(n);
    cate:=1;
    i:=1;
    while ((i*i) shr 1)+(i shr 1)<=n do
        begin
        if (v[i shl 3]=0)and(1 shr i=0)and(1 shr 7=0) then
            begin
            j:=((i*i)shl 1)+(i shl 1);
            while ((j shl 1)+1 <=n) do
                begin
                v[j shr 3]:=v[j shr 3] or((1 shl j)and(1 shl 7));
                end;
            end;
        end;
    i:=1;
    while 2*i+1<=n do
        begin
        if (v[i shr 3]=0) and (1 shl i=0) and (1 shl 7=0) then inc(cate);
        i:=i+1;
        end;
    write(cate);
    close(input);close(output);
end.