Pagini recente » Cod sursa (job #505027) | Cod sursa (job #2960200) | Cod sursa (job #409115) | Cod sursa (job #1636184) | Cod sursa (job #2803)
Cod sursa(job #2803)
var j,r,c,x,t:longint;
f,g:text;
n:longint;
function cif(n:longint):integer;
var c,y,i,l:integer;
a:array[1..100]of integer;
begin
for i:=1 to n-1 do
begin
a[n]:=1;
a[i]:=0;
end;
for l:=1 to n do
begin
y:=0;
for i:=n downto 1 do
begin
a[i]:=a[i]*n+y;
y:=a[i] div 10;
a[i]:=a[i] mod 10;
end;end;
cif:=a[n];
end;
begin
assign(f,'cifra.in');reset(f);
assign(g,'cifra.out');rewrite(g);
readln(f,t);
for r:=1 to t do
begin
readln(f,n); x:=0;
for j:=1 to n do
begin
x:=x+cif(j);
x:=x mod 10;
end;
writeln(g,x+1);
end;
close(f);close(G);
end.