Chủ Nhật, 21 tháng 5, 2017

BBSORT

Const f1='BBSORT.INP';
f2='BBSORT.OUT';
Var F: Array [1..1000000] of longint;
n,k,t,j,i: longint;

Procedure nhap;
Begin
Read (n,k);
End;

Procedure taomang;
Var i: longint;
Begin
f[1]:=1;
f[2]:=1;
for i:=3 to n do
    f[i]:= (f[i-2]+ f[i-1]) mod 128;
End;

Procedure sapxep;
Var i,j,t,min:longint;
Begin
    For i:=1 to n-1 do
        Begin
        min:=i;
        For j:=i+1 to n do
            If F[min]>F[j] then min:=j;
        t:=F[min];
        F[min]:=F[i];
        F[i]:=t;
        End;
    Writeln (f[k]);
end;

Begin
Assign (input,f1); Reset(input);
Assign (output,f2); Rewrite(output);
nhap;
taomang;
sapxep;
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.