Pagini recente » Cod sursa (job #1574329) | Profil Djok | Cod sursa (job #3209987) | Cod sursa (job #2072566) | Cod sursa (job #142395)
Cod sursa(job #142395)
program p12;
var f,g:text;
j,n,uc,uc1,i,t,c:longint;
begin
assign(f,'cifra.in');reset(f);
assign(g,'cifra.out');rewrite(g);
readln(f,n);
for i:=1 to n do
begin
uc1:=0;
uc:=0;
readln(f,t);
for j:=1 to t do
begin
c:=j mod 10;
case c of
1,6,5:uc:=c;
4,9:if j mod 2=1 then uc:=c
else uc:=c*c;
2,3,7,8: if j mod 4=1 then uc:=c
else if j mod 4=2 then uc:=c*c
else if j mod 4=3 then uc:=c*c*c
else uc:=c*c*c*c;
end;
uc1:=(uc1+uc)mod 10;
end;
writeln(g,uc1);
end;
close(g);
close(f);
end.