Pagini recente » Cod sursa (job #73586) | Cod sursa (job #1592698) | Cod sursa (job #1846159) | Cod sursa (job #610569) | Cod sursa (job #284799)
Cod sursa(job #284799)
var s:string;
nr,s1,n,t,i:longint;
x:shortint;
begin
assign(input,'cifra.in');
reset(input);
assign(output,'cifra.out');
rewrite(output);
readln(input,t);
for i:=1 to t do
begin
readln(input,s);
n:=length(s);
if n=1 then s1:=ord(s[1])-48
else
begin
s1:=ord(s[n-1])-48;
s1:=10*s1+(ord(s[n])-48);
end;
nr:=4*(s1 div 20);
s1:=s1 mod 20;
x:=1;
if s1>=x then nr:=nr+1;
if s1>=x+1 then nr:=nr+4;
if s1>=x+2 then nr:=nr+7;
if s1>=x+3 then nr:=nr+6;
if s1>=x+4 then nr:=nr+5;
if s1>=x+5 then nr:=nr+6;
if s1>=x+6 then nr:=nr+3;
if s1>=x+7 then nr:=nr+6;
if s1>=x+8 then nr:=nr+9;
if s1>=x+10 then nr:=nr+1;
if s1>=x+11 then nr:=nr+6;
if s1>=x+12 then nr:=nr+3;
if s1>=x+13 then nr:=nr+6;
if s1>=x+14 then nr:=nr+5;
if s1>=x+15 then nr:=nr+6;
if s1>=x+16 then nr:=nr+7;
if s1>=x+17 then nr:=nr+4;
if s1>=x+18 then nr:=nr+9;
writeln(output,nr mod 10);
end;
close(input);
close(output);
end.