Pagini recente » Monitorul de evaluare | Cod sursa (job #1336992) | Cod sursa (job #1932053) | Cod sursa (job #1649448) | Cod sursa (job #1281185)
var t,x,y,s,n,uc,p,i,j:longint;
a:array[0..9,1..4]of integer;
f,g:text;
begin
for i:=0 to 9 do
begin
a[i,1]:=i;
for j:=2 to 4 do
a[i,j]:=(a[i,j-1]*i) mod 10;
end;
assign(f,'cifra.in');
reset(f);
assign(g,'cifra.out');
rewrite(g);
readln(f,t);
for j:=1 to t do
begin
readln(f,n);
s:=0;
for i:=1 to n do
begin
x:=i mod 10;
y:=i mod 4;if y=0 then y:=4;
s:=s+a[x,y];s:=s mod 10;
end;
writeln(g,s);
end;
close(f);
close(g);
end.