Skrytý text:
program zahonky;
var n:shortint;p:longint;
function mrkev(i:shortint):longint;
begin
if i=1 then mrkev:=1;
if i=2 then mrkev:=2;
if i>2 then mrkev:=mrkev(i-1)+mrkev(i-2);
end;
function zah(j:shortint):longint;
begin
if j=1 then zah:=2;
if j>1 then zah:=zah(j-1)+mrkev(j-1);
end;
begin
readln(n);
if n<=44 then
begin
if n>0 then
begin
p:=zah(n);
writeln(p);
end;
end;
end.
Skrytý text:
program zahonky;
var n:shortint;p:longint;
function mrkev(i:shortint):longint;
begin
if i=1 then mrkev:=1;
if i=2 then mrkev:=2;
if i>2 then mrkev:=mrkev(i-1)+mrkev(i-2);
end;
function petrzel(k:shortint):longint;
begin
if k=1 then petrzel:=1;
if k>1 then petrzel:=mrkev(k-1);
end;
function zah(j:shortint):longint;
begin
if j=1 then zah:=2;
if j>1 then zah:=petrzel(j)+mrkev(j);
end;
begin
readln(n);
if n<=44 then
begin
if n>0 then
begin
p:=zah(n);
writeln(p);
end;
end;
end.
oba dva dopadli stejně bodově
Skrytý text:
Jailing user 'codex' (UID 1003, GID 1003) into directory '/home/codex/workers/eval2/jail'
Initializing... OK
Preparing sandbox... running locally (INSECURE), OK
Finding source... ./inbox/source.pas
Compiling... OK
Test 1... <init> <run> <check> OK:OK (100 points)
Test 2... <init> <run> <check> OK:OK (300 points)
Test 3... <init> <run> TO:Time limit exceeded
Řeším úlohy o záhoncích mrkve a petržele a potřebuji program uryhclit aby prošel testem v codexu.
jinak dle zadání se má načíst počet záhonků n nejvíc 44. Děkuji.