Pagini recente » Rating Claudiu Negru (astroman389) | Cod sursa (job #949679) | Cod sursa (job #2953167) | Cod sursa (job #148537)
Cod sursa(job #148537)
var f,g:text;
t,n,i:longint;
e:integer;
c:string;
function up(x,y:longint):byte;
begin
if y=0 then up:=1
else
up:=(up(x,y-1)*x) mod 10;
end;
function suma(z:longint):longint;
begin
if z=0 then suma:=0
else
suma:=(suma(z-1)+up(z,z)) mod 10;
end;
begin
assign(f,'date.in');
assign(g,'date.out');
reset(f);
rewrite(g);
readln(f,t);
for i:=1 to t do
begin
readln(f,c); delete(c,1,length(c)-2);
val(c,n,e);
writeln(g,suma(n));
end;
close(f);
close(g);
end.