Pagini recente » Cod sursa (job #2551713) | Cod sursa (job #3140850) | Cod sursa (job #258697) | Cod sursa (job #1607312) | Cod sursa (job #1977677)
var f,g:text;
s,p,i,x,n,j:longint;
begin
assign(f,'cifra.in');
assign(g,'cifra.out');
reset(f);
rewrite(g);
read(f,n);
for j:=1 to n do
begin
s:=0;
read(f,x);
for i:=1 to x do
begin
p:=i mod 10;
if p=1 then s:=(s+1) mod 10;
if p=0 then s:=(s+0) mod 10;
if p=5 then s:=(s+5) mod 10;
if p=6 then s:=(s+6) mod 10;
if p=2 then
begin
if i mod 4=1 then s:=(s+2) mod 10;
if i mod 4=2 then s:=(s+4) mod 10;
if i mod 4=3 then s:=(s+8) mod 10;
if i mod 4=0 then s:=(s+6) mod 10;
end;
if p=3 then
begin
if i mod 4=1 then s:=(s+3) mod 10;
if i mod 4=2 then s:=(s+9) mod 10;
if i mod 4=3 then s:=(s+7) mod 10;
if i mod 4=0 then s:=(s+1) mod 10;
end;
if p=7 then
begin
if i mod 4=1 then s:=(s+7) mod 10;
if i mod 4=2 then s:=(s+9) mod 10;
if i mod 4=3 then s:=(s+3) mod 10;
if i mod 4=0 then s:=(s+1) mod 10;
end;
if p=8 then
begin
if i mod 4=1 then s:=(s+8) mod 10;
if i mod 4=2 then s:=(s+4) mod 10;
if i mod 4=3 then s:=(s+2) mod 10;
if i mod 4=0 then s:=(s+6) mod 10;
end;
if p=4 then
begin
if i mod 4=1 then s:=(s+4) mod 10;
if i mod 4=2 then s:=(s+6) mod 10;
if i mod 4=3 then s:=(s+4) mod 10;
if i mod 4=0 then s:=(s+6) mod 10;
end;
if p=9 then
begin
if i mod 4=1 then s:=(s+9) mod 10;
if i mod 4=2 then s:=(s+1) mod 10;
if i mod 4=3 then s:=(s+9) mod 10;
if i mod 4=0 then s:=(s+1) mod 10;
end;
end;
writeln(g,s);
end;
close(f);
close(g);
end.