Mai intai trebuie sa te autentifici.
Cod sursa(job #222543)
Utilizator | Data | 23 noiembrie 2008 13:05:37 | |
---|---|---|---|
Problema | Divizori Primi | Scor | 30 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.86 kb |
program gaju;
type ve=array[1..100000]of longint;
var s:array[1..100000,0..8]of longint;
a,b:ve;
k:byte;
h,n,t,max:longint;
f,g:text;
procedure afis;
var i:longint;
begin
for i:=1 to t do writeln(g,s[a[i],b[i]]);
end;
procedure eratos(n:longint);
var v:ve;
i,j:longint;
begin
fillchar(v,sizeof(v),0);
fillchar(s,sizeof(s),0);
s[1,0]:=1;
i:=2;
while i<=n do begin
if v[i]=0 then begin
j:=2*i;
while j<=n do begin
v[j]:=v[j]+1;
j:=j+i;
end;end;
for j:=0 to 8 do s[i,j]:=s[i-1,j];
if s[i,v[i]]<i then s[i,v[i]]:=i;
i:=i+1;
end;
afis;
end;
begin
assign(f,'divprim.in');reset(f);
assign(g,'divprim.out');rewrite(g);
readln(f,t);
for h:=1 to t do begin
readln(f,a[h],b[h]);
if max<a[h]then max:=a[h];
end;
eratos(max);
close(g);
end.