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

CTNBULLS pascal

const hs=2111992;
var n,k:longint;
    f:array[0..100001] of longint;

Procedure Process;
var i,j:longint;
begin
    read (n,k);
    for i:=1 to k+1 do 
        f[i]:=i+1;
    for i:=k+2 to n do 
        f[i]:=((f[i-k-1] mod hs)+(f[i-1] mod hs)) mod hs;
    write(f[n]);
end;

begin
    assign(input,'CTNBULLS.inp'); reset(input);
    assign(output,'CTNBULLS.out'); rewrite(output);
    Process;
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.