Pagini recente » Cod sursa (job #1065994) | Cod sursa (job #1150970) | Cod sursa (job #1548675) | Cod sursa (job #2781931) | Cod sursa (job #805561)
Cod sursa(job #805561)
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;
f,g: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(f,'nunta.in');
assign(g,'nunta.out');
reset(f);
rewrite(g);
readln(f,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(g,'1')
else
if m mod 3=1 then
for i:=lim to max do
write(g,c[i])
else
if m mod 3=2 then
for i:=lim to max do
write(g,a[i])
else
for i:=lim to max do
write(g,b[i]);
close(g);
end.