Pagini recente » Cod sursa (job #804018) | Cod sursa (job #1316475) | Cod sursa (job #2165853) | jc2015 | Cod sursa (job #584720)
Cod sursa(job #584720)
var i,j,n,m,suma:long64;
f,g:text;
function rez2(x:longint):longint;
var y,h,rez:longint;
begin
y:=x;
x:=x mod 10;
if x=0 then rez:=0;
if x=1 then rez:=1;
if x=2 then
begin
h:=y mod 4;
if h=1 then rez:=2;
if h=2 then rez:=4;
if h=3 then rez:=8;
if h=0 then rez:=6;
end;
if x=3 then
begin
h:=y mod 4;
if h=1 then rez:=3;
if h=2 then rez:=9;
if h=3 then rez:=7;
if h=0 then rez:=1;
end;
if x=4 then
begin
h:=y mod 2;
if h=1 then rez:=4;
if h=0 then rez:=6;
end;
if x=5 then rez:=5;
if x=6 then rez:=6;
if x=7 then
begin
h:=y mod 4;
if h=1 then rez:=7;
if h=2 then rez:=9;
if h=3 then rez:=3;
if h=4 then rez:=1;
end;
if x=8 then
begin
h:=y mod 4;
if h=1 then rez:=8;
if h=2 then rez:=4;
if h=3 then rez:=2;
if h=0 then rez:=6;
end;
if x=9 then
begin
h:=y mod 2;
if h=1 then rez:=9;
if h=0 then rez:=1;
end;
rez2:=rez;
end;
begin
assign(f,'cifra.out');
rewrite(f);
close(f);
assign(f,'cifra.in');
reset(f);
readln(f,m);
j:=0;
while j<m do
begin
readln(f,n);
inc(j);
suma:=0;
for i:=1 to n do
suma:=(suma+rez2(i)) mod 10;
assign(g,'cifra.out');
append(g);
writeln(g,suma mod 10);
close(g);
end;
close(f);
end.