Cod sursa(job #2129964)

Utilizator tiuleniviskvisckun Grisha tiulenivisk Data 13 februarie 2018 12:15:17
Problema Cifra Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.44 kb
program p1;
var n,x,z,i,j:longint;
v:array[1..10000] of integer;
p:array[1..10000] of integer;
f1,f2:text;
begin
assign(f1,'cifra.in');
assign(f2,'cifra.out');
reset(f1);
rewrite(f2);
readln(f1,n);
for i:=1 to n do 
begin
readln(f1,p[i]);
end;
z:=1;
for i:= 2 to n do begin
x:=1;
for j:= 1 to i do
x:=x*i;
z:=x+z;
v[i]:=z mod 10;
end;
v[1]:=1;
for i:=1 to n do begin
writeln(f2,v[p[i]]);
end;
close(f1);
close(f2);
end.