Pagini recente » Cod sursa (job #816080) | Cod sursa (job #503231) | Cod sursa (job #2160343) | Cod sursa (job #1730679) | Cod sursa (job #47435)
Cod sursa(job #47435)
Program cifra;
Var f,ff:text;
v:integer;
s,j,m,n,i:longint;
h,st:string;
a:array[0..99] of 0..9;
Begin
s:=0;
a[0]:=0;
for j:=1 to 99 do
begin
if (j mod 10=0) or (j mod 10=1) or (j mod 10=5) or (j mod 10=6) then s:=(s+j mod 10) mod 10;
if j mod 10=2 then
case j mod 4 of
2:s:=(s+4) mod 10;
0:s:=(s+6) mod 10;
end;
if j mod 10=3 then
case j mod 4 of
3:s:=(s+7) mod 10;
1:s:=(s+3) mod 10;
end;
if j mod 10=4 then s:=(s+6) mod 10;
if j mod 10=7 then
case j mod 4 of
3:s:=(s+3) mod 10;
1:s:=(s+7) mod 10;
end;
if j mod 10=8 then
case j mod 4 of
2:s:=(s+4) mod 10;
0:s:=(s+6) mod 10;
end;
if j mod 10=9 then s:=(s+9) mod 10;
a[j]:=s;
end;
assign(ff,'cifra.in');
reset(ff);
readln(ff,m);
assign(f,'cifra.out');
rewrite(f);
for i:=1 to m do
begin
readln(ff,st);
h:='';
if length(st)<>1 then h:=st[length(st)-1];
h:=h+st[length(st)];
val(h,n,v);
Writeln(f,a[n]);
end;
close(f);
close(ff);
End.