Cod sursa(job #1024915)

Utilizator hungntnktpHungntnktp hungntnktp Data 9 noiembrie 2013 12:21:38
Problema Descompuneri Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 2.72 kb
program DESC;
Const
        fi='desc.in';
        fo='desc.out';
Var     N,K,ans:longint;
        p,q:array[1..100] of longint;

        Function NTO(n:longint):boolean;
        Var i,step:longint;
        begin
                NTO:=false;
                IF n=2 then exit(true);
                IF n=3 then exit(true);
                IF n=5 then exit(true);
                IF (n=0) or (n=1) then exit(false);
                If (n mod 2=0) or (n mod 3=0) then exit;
                i:=5;
                step:=2;
                While i<=sqrt(n) do
                begin
                         If n mod i=0 then exit;
                         i:=i+step;
                         step:=6-step;
                end;
                exit(true);
        end;

        Function somu(p,n:longint):longint;
        Var count:longint;
        begin
                count:=0;
                While n<>0 do
                begin
                       n:=n div p;
                       inc(count,n);
                end;
                exit(count);
        end;

        procedure Phantich;
        Var i,j,temp,count:longint;
        begin
                temp:=2;
                count:=0;
                While n<>1 do
                begin
                        IF NTO(N) then
                        begin
                                 inc(count);
                                 p[count]:=n;
                                 q[count]:=1;
                        end
                        else
                        begin
                                 While (n mod temp<>0) and (temp<=N) do
                                 begin
                                         inc(temp);
                                         While NTO(temp)=false do inc(temp);
                                 end;
                                 inc(count);
                                 p[count]:=temp;
                                 While n mod temp=0 do
                                 begin
                                         inc(q[count]);
                                         n:=n div temp;
                                 end;
                        end;
                end;
                ans:=1;
                For i:=1 to count do ans:=ans*(q[i]+1);
        end;

        procedure input;
        Var f:Text;
        begin
                Assign(f,fi);Reset(f);
                Read(f,N,k);
                close(f);
        end;

        procedure output;
        Var f:text;
        begin
                Assign(f,fo);Rewrite(f);
                Writeln(f,ans);
                close(f);
        end;

BEGIN
        input;
        Phantich;
        output;
END.