Pagini recente » Cod sursa (job #2405383) | Cod sursa (job #2766721) | Cod sursa (job #497541) | Cod sursa (job #2980354) | Cod sursa (job #524854)
Cod sursa(job #524854)
var x:string; i,z,j,v,n:longint;
cod:integer;
f,g:text;
FUNCTION fact(x:longint):longint;
var c,p,cp:longint;
begin
c:=x mod 10;
p:=x mod 100;
if c= 0 then cp:=0 else
if c=1 then cp:=1 else
if c=2 then if p=0 then cp:=1
else if p mod 4=1 then cp:=2
else if p mod 4=2 then cp:=4
else if p mod 4=3 then cp:=8
else if p mod 4=0 then cp:=6;
if c=3 then if p=0 then cp:=1
else if p mod 4=1 then cp:=3
else if p mod 4=2 then cp:=9
else if p mod 4=3 then cp:=7
else if p mod 4=0 then cp:=1;
if c=4 then if p=0 then cp:=1
else if p mod 2<>0 then cp:=4
else if p mod 2=0 then cp:=6;
if c=5 then if p=0 then cp:=1
else cp:=5;
if c=6 then if p=0 then cp:=1
else cp:=6;
if c=7 then if p=0 then cp:=1
else if p mod 4=1 then cp:=7
else if p mod 4=2 then cp:=9
else if p mod 4= 3 then cp:=3
else if p mod 4=0 then cp:=1;
if c=8 then if p=0 then cp:=1
else if p mod 4=1 then cp:=8
else if p mod 4=2 then cp:=4
else if p mod 4=3 then cp:=2
else if p mod 4=0 then cp:=6;
if c=9 then if p mod 1=0 then cp:=1
else if p=0 then cp:=1
else if p mod 2<>0 then cp:=9
else if p mod 2=0 then cp:=1;
fact:=cp;
end;
begin
assign(f,'cifra.in');reset(f);
assign(g,'cifra.out');rewrite(g);
readln(f,n);
for i:= 1 to n do begin
readln(f,x);
val(x,v,cod);
end;
j:=0;
for z:=1 to v do
j:=j+ fact(z);
writeln(g,j mod 10);
close(g);close(f);
end.