Pagini recente » Profil Rares_99 | Cod sursa (job #955027) | Cod sursa (job #1005331) | Cod sursa (job #1521746) | Cod sursa (job #780043)
Cod sursa(job #780043)
Program nunta;
type tip=array [1..300] of byte;
const max=300;
var a,b,c:array [1..300] of byte;
i,lim,m,k,n:integer;
fi,fo:text;
procedure aduna(var a,b,c:tip);
var t,s,j:integer;
begin
t:=0; s:=0;
for j:=max downto lim do begin
s:=a[j]+b[j]+t;
c[j]:=s mod 10;
t:=s div 10;
end;
if t<>0 then begin
dec(lim);
c[lim]:=t;
end;
end;
begin
assign(fi,'nunta.in');
assign(fo,'nunta.out');
reset(fi); rewrite(fo);
readln(fi,n);
a[max]:=1; b[max]:=1; lim:=max;
repeat
inc(m);
if m mod 3=1 then aduna(a,b,c)
else if m mod 3=2 then aduna(b,c,a)
else aduna(a,c,b);
until m>=n-1;
if n=1 then write(fo,'1') else
if m mod 3=1 then for i:=lim to max do write(fo,c[i])
else if m mod 3=2 then for i:=lim to max do write(fo,a[i])
else for i:=lim to max do write(fo,b[i]);
close(fo);
end.