Cod sursa(job #431993)

Utilizator ionutz32Ilie Ionut ionutz32 Data 1 aprilie 2010 18:44:30
Problema Suma si numarul divizorilor Scor 70
Compilator fpc Status done
Runda Arhiva educationala Marime 1.08 kb
var v:array[1..1000000] of longint;
t,i,j,last,n:longint;
x,nr,suma,aux,p,pow:int64;
f,g:text;
begin
assign(f,'ssnd.in');
assign(g,'ssnd.out');
reset(f);rewrite(g);
readln(f,t);
n:=1000000;
for i:=2 to n do
    if v[i]=0 then
       begin
       for j:=i to n div i do
           v[i*j]:=1;
       if last>0 then
          v[last]:=i;
       last:=i;
       end;
for i:=1 to t do
    begin
    readln(f,x);
    if x=1 then
       begin
       writeln(g,'1 1');
       continue;
       end;
    nr:=1;
    suma:=1;
    j:=2;
    aux:=x;
    while (x>1) and (j<=sqrt(aux)) do
          begin
          p:=0;
          pow:=1;
          while x mod j=0 do
                begin
                inc(p);
                x:=x div j;
                pow:=pow*j;
                end;
          pow:=pow*j;
          nr:=nr*(p+1);
          suma:=suma*((pow-1) div (j-1)) mod 9973;
          j:=v[j];
          end;
    if x>1 then
       writeln(g,nr*2,' ',suma*((x*x-1) div (x-1)) mod 9973)
    else
        writeln(g,nr,' ',suma);
    end;
close(f);close(g);
end.