NKABD - Số phong phú

Tác giả: ll931110

Ngôn ngữ: Pascal

Program NKABD;
        Const
                input  = '';
                output = '';
        Var
                a: array[1..100000] of longint;
              l,r: longint;

Procedure init;
          Var
                f: text;
          Begin
                Assign(f, input);
                        Reset(f);
                        Readln(f, l, r);
                Close(f);
          End;

Procedure sieve;
          Var
                i,k: longint;
          Begin
                Fillchar(a, sizeof(a), 0);

                For i:= 1 to 50000 do
                        Begin
                                k:= 2;
                                While k * i <= 100000 do
                                        Begin
                                                a[k * i]:= a[k * i] + i;
                                                inc(k);
                                        End;
                        End;
          End;

Procedure solve;
          Var
                  f: text;
                i,s: longint;
          Begin
                Assign(f, output);
                        Rewrite(f);
                                s:= 0;
                                For i:= l to r do if a[i] > i then inc(s);
                        Writeln(f, s);
                Close(f);
          End;

Begin
        init;
        sieve;
        solve;
End.


Download