Pagini recente » Cod sursa (job #2970677) | Cod sursa (job #309398) | Cod sursa (job #2970598) | Cod sursa (job #1408687) | Cod sursa (job #168904)
Cod sursa(job #168904)
var f,g:text;
i,t,n,uc,j,s:longint;
function putere(a:integer;n:integer):integer;
var x:integer;
Begin
x:=0;
if a=4 then
if n mod 2=0 then
x:=x+6
else
x:=x+1;
if a=9 then
if n mod 2=0 then
x:=x+1
else
x:=x+9;
if a=2 then
Begin
if (n mod 2=0) and (n mod 4<>0) then
x:=x+4;
if n mod 4=0 then
x:=x+6;
if n mod 2<>0 then
if n mod 3=0 then
x:=x+8
else
x:=x+2
End;
if a=3 then
Begin
if (n mod 2=0) and (n mod 4<>0) then
x:=x+9;
if n mod 4=0 then
x:=x+1;
if n mod 2<>0 then
if n mod 3=0 then
x:=x+7
else
x:=x+3
End;
if a=7 then
Begin
if (n mod 2=0) and (n mod 4<>0) then
x:=x+9;
if n mod 4=0 then
x:=x+1;
if n mod 2<>0 then
if n mod 3=0 then
x:=x+3
else
x:=x+7
End;
if a=8 then
Begin
if (n mod 2=0) and (n mod 4<>0) then
x:=x+4;
if n mod 4=0 then
x:=x+6;
if n mod 2<>0 then
if n mod 3=0 then
x:=x+2
else
x:=x+8
End;
putere:=x;
end;
begin
assign(f ,'cifra.in');
assign(g ,'cifra.out');
rewrite(g);
reset(f);
readln(f,t);
i:=1;
s:=0;
while i<=t do
Begin
readln(f,n);
s:=0;
for j:=1 to n do
BEgin
uc:=j mod 10;
if uc=5 then
s:=s+uc;
if uc=6 then
s:=s+uc;
if uc=1 then
s:=s+uc;
if (uc<>5) and (uc<>6) then
s:=s+putere(uc,j);
ENd;
s:=s mod 10;
writeln(g,s);
i:=i+1;
End;
close(f);
close(g);
end.