Cod sursa(job #631470)

Utilizator Flavius94.Ianchis Flavius Flavius94. Data 8 noiembrie 2011 09:49:52
Problema Patrate2 Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.85 kb
var a:array [0..1000005] of byte;

b1,b2:array [1..1 shl 15] of char;

i,j,n,l,lim:longint;

fi,fo:text;
procedure inmulteste(n:longint);
var t,i,s,code,x,k:longint;

s2:string;
begin
t:=0; k:=0;

for i:=l downto lim do  begin

s:=n*a[i]+t;

t:=s div 10;

a[i]:=s mod 10;

end;

if t>0 then begin

str(t,s2);

lim:=lim-length(s2);

for s:=lim to i-1 do begin

inc(k);

val(s2[k],x,code);

a[s]:=x;

end;

end;
end;
begin
assign(fi,'patrate2.in');

assign(fo,'patrate2.out');
settextbuf(fi,b1);
settextbuf(fo,b2);
reset(fi);

rewrite(fo);
readln(fi,n);
l:=1000000; a[1000000]:=1; lim:=1000000;

for i:=1 to trunc(n*n/25) do inmulteste(33554432);

j:=trunc(n*n/25)*25;

while j<n*n do begin inmulteste(2); inc(j); end;

for i:=2 to n do inmulteste(i);

for i:=lim to 1000000 do write(fo,a[i]);
close(fo);
end..