Pagini recente » Cod sursa (job #2707705) | preONI 2007, Runda 4, Clasa a 9-a si gimnaziu | Cod sursa (job #2427851) | Cod sursa (job #2665847) | Cod sursa (job #744754)
Cod sursa(job #744754)
program TheVic1;
var int,outo:text; N:string; T,pow,j,i,N2,cod,leng:integer;
function Power(x,y : integer) : longint;
begin
if y=0 then power:=1 else power:=x*power(x,y-1);
end;
begin
assign(int, 'cifra.in');
assign(outo, 'cifra.out');
reset(int);
rewrite(outo);
readln(int, T);
For i:=1 to T do
begin
readln(int,N);
val(N,N2,cod);
pow:=0;
for j:=1 to N2 do pow:=pow+power(j,j);
str(pow,N);
leng:=length(N);
writeln(outo,N[leng]);
end;
close(int);
close(outo);
end.