Pagini recente » Cod sursa (job #1527314) | Cod sursa (job #92846) | Cod sursa (job #2419880) | Cod sursa (job #40599) | Cod sursa (job #304255)
Cod sursa(job #304255)
program cifra;
var t:array[1..100]of 0..9;
cit:string;
n,i,j,s,l,k,l1,c:longint;
f,g:text;
procedure lucru;
begin
s:=0;
read(f,n);
for j:=1 to n do
begin
l:=j;
l1:=j;
for k:=2 to (j mod 10) do
l:=((l mod 10)*(l1 mod 10))mod 10;
inc(s,l);
s:=s mod 10;
end;
writeln(g,s);
end;
procedure back(var c:longint;cit:string);
var j:longint;
begin
if c<length(cit) then
for j:=1 to 10 do
begin
inc(c);
lucru;
back(c,cit);
end;
end;
begin
assign(f,'cifra.in');
reset(f);
assign(g,'cifra.out');
rewrite(g);
read(f,cit);
for i:=1 to length(cit) do
if cit[i]='0' then t[i]:=0
else
if cit[i]='1' then t[i]:=1
else
if cit[i]='2' then t[i]:=2
else
if cit[i]='3' then t[i]:=3
else
if cit[i]='4' then t[i]:=4
else
if cit[i]='5' then t[i]:=5
else
if cit[i]='6' then t[i]:=6
else
if cit[i]='7' then t[i]:=7
else
if cit[i]='8' then t[i]:=8
else
if cit[i]='9' then t[i]:=9;
c:=1;
for i:=1 to length(cit) do
for i:=1 to t[i] do
if length(cit)>1 then back(c,cit)
else lucru;
close(f);
close(g);
end.