Thứ Tư, 27 tháng 4, 2022

VSTEPS pascal

const maxk=500000;   maxn=10000000;
var
   f:array[1..maxn] of longint;
   hong:array[1..maxn] of boolean;
   k,i,n,x:longint;

procedure nhap;
begin
    readln(n,k);
    {danh dau nhung bac hong}
    for i:=1 to n do hong[i]:=false;
    for i:=1 to k do
    begin
        read(x);
        hong[x]:=true;
    end;
end;

procedure xuli;
begin
    {tinh f2, f3}
    if hong[2] then f[2]:=0
    else f[2]:=1;
    if hong[3] then f[3]:=0
    else
        if hong[2] then f[3]:=1
        else f[3]:=2;

    {tinh f[n]}
    for i:=4 to n do
        if hong[i] then f[i]:=0
        else
            f[i]:=(f[i-1]+f[i-2]) mod 14062008;
    writeln(f[n]);
    end;
begin
     assign(input,'vsteps.inp');reset(input);
     assign(output,'vsteps.out');rewrite(output);

     xuli;
     close(input);close(output);
end.

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.