Cod sursa(job #614321)

Utilizator KennedyKennedy Kennedy Data 5 octombrie 2011 22:49:35
Problema Suma si numarul divizorilor Scor 20
Compilator fpc Status done
Runda Arhiva educationala Marime 1.73 kb
Program suma_div;
var f1,f2:text;
       n:1..1000;
       i,j,j1,i1:longint;
       nr:array[1..1000] of real;
       ciur:array[2..100000000] of boolean;
       ak:array[1..1000] of integer;
       pk:array[1..1000] of 0..1;
       s1,s2,x,john:real;




begin
     assign(f1,'ssnd.in'); reset(f1); readln(f1,n); read(f1,nr[1]); john:=nr[1];
     for i:=2 to n do begin read(f1,nr[i]);if nr[i]>john then john:=nr[i]; end; close(f1);
     assign(f2,'ssnd.out'); rewrite(f2);
     for i:=2 to trunc(john) do ciur[i]:=true;
     for i:=1 to n do begin
                      for j:=2 to trunc(sqrt(nr[i])) do if ciur[j] then for j1:=2 to trunc(nr[i]) div j do ciur[j*j1]:=false;
                      j:=1; john:=0;
                      while nr[i]<>1 do begin
                                        j:=j+1; ak[j]:=0;
                                        if ciur[j] then while trunc(nr[i]) mod j=0  do begin
                                                                                      nr[i]:=trunc(nr[i]) div j;
                                                                                      ak[j]:=ak[j]+1;
                                                                                      pk[j]:=1;
                                                                                      end;
                                        end;
                      s1:=1;
                      for j1:=j downto 1 do s1:=s1*(ak[j1]+1);
                      s2:=1;
                      for j1:=j downto 1 do if pk[j1]=1 then begin x:=1;for i1:=1 to ak[j1]+1 do x:=x*j1; s2:=s2/(j1-1)*(x-1); end;


                      writeln(f2,trunc(s1),' ',trunc(s2) mod 9973);
                      end;

     close(f2);
end.