MCOINS - Coins Game

Tác giả: RR

Ngôn ngữ: Pascal

{$R+,Q+}
uses math;
const
  FINP='';
  FOUT='';
  MAXN=1000001;
var
  f1,f2:text;
  f:array[0..MAXN] of longint;
  m,k,l:longint;
procedure openF;
begin
  assign(f1,FINP); reset(f1);
  assign(f2,FOUT); rewrite(f2);
end;
procedure closeF;
begin
  close(f1);
  close(f2);
end;
procedure inp;
begin
  read(f1,k,l,m);
end;
procedure solve;
var
  i:longint;
begin
  f[0]:=0;
  for i:=1 to MAXN do
    begin
      if f[i-1]=0 then
        begin
          f[i]:=1;
          continue;
        end;
      if (i>=k) and (f[i-k]=0) then
        begin
          f[i]:=1;
          continue;
        end;
      if (i>=l) and (f[i-l]=0) then
        begin
          f[i]:=1;
          continue;
        end;
    end;
end;
procedure ans;
var
  i,u:longint;
begin
  for i:=1 to m do
  begin
    read(f1,u);
    if f[u]=1 then write(f2,'A')
    else write(f2,'B')
  end;
  writeln;
end;
begin
  openF;
  inp;
  solve;
  ans;
  closeF;
end.

Download