## Editorial for Coins Game

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Lưu ý: Các code mẫu dưới đây chỉ mang tính tham khảo và có thể không AC được bài tập này

#### Code mẫu của flashmt

const fi='';
fo='';
maxn=1000000;
var n,x,y,max,i:longint;
p:array[0..maxn+10] of boolean;
a:array[1..200] of longint;

procedure rf;
begin
assign(input,fi);
reset(input);
max:=0;
for i:=1 to n do
begin
if a[i]>max then max:=a[i];
end;
close(input);
end;

procedure pr;
begin
p[0]:=true; p[x]:=false; p[y]:=false;
for i:=1 to x-1 do p[i]:=not p[i-1];
for i:=x+1 to y-1 do p[i]:=not (p[i-1] or p[i-x]);
for i:=y+1 to max do p[i]:=not (p[i-1] or p[i-x] or p[i-y]);
end;

procedure wf;
begin
assign(output,fo);
rewrite(output);
for i:=1 to n do
if p[a[i]] then write('B') else write('A');
close(output);
end;

begin
rf;
pr;
wf;
end.


#### Code mẫu của happyboy99x

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define sz(a) int((a).size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(), _e = (c).end(); i != _e; ++i)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i,n) for(int i = 0, _n = (n); i < _n; ++i)
#define repd(i,n) for(int i = (n)-1; i >= 0; --i )
#define fo(i,a,b) for(int i = (a), _b = (b); i <= _b; ++i)
#define fod(i,a,b) for(int i = (a), _b = (b); i >= _b; --i)

#define INF 1000000000
#define N 1000000

int k, l, m, n;
bool f[N+1];

int main() {
#ifndef ONLINE_JUDGE
freopen( "input.txt", "r", stdin );
//freopen( "output.txt", "w", stdout );
#endif
scanf("%d%d%d",&k,&l,&m);
f[0] = 0;
#define F(i) (i >= 0 ? f[i] : 1)
fo(i,1,N) {
f[i] = !F(i-1) || !F(i-k) || !F(i-l);
/*f[i] = (F(i-2) && F(i-k-1) && F(i-l-1))
|| (F(i-k-1) && F(i-k-k) && F(i-k-l))
|| (F(i-l-1) && F(i-l-k) && F(i-l-l));*/
}
while(m--) {
scanf("%d",&n);
putchar( f[n] ? 'A' : 'B' );
}
putchar(10);
return 0;
}


program MCOINS;
uses    math;
const   maxn=1000006;
fi='';
var     f:array[-1..maxn] of boolean;
inp:text;
k,l,m,lim,n,i,j:longint;
begin
assign(inp,fi);reset(inp);
lim:=0;
f[0]:=true;
for j:=1 to m do begin
if n>lim then begin
for i:=lim+1 to n do
if f[i-1] or f[max(i-k,-1)] or f[max(i-l,-1)] then
f[i]:=false
else f[i]:=true;
lim:=n;
end;
if f[n] then write('B')
else write('A');
end;
end.


{$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.  #### Code mẫu của hieult #include <stdio.h> //#include <conio.h> main() { char f[1000001]; long a,b,T,n; scanf("%ld %ld %ld",&a,&b,&T); f[1]='A';f[a]='A';f[b]='A'; for(long i=2;i<a;i++) { if(i%2==0) f[i]='B'; else f[i]='A'; } for(long i=a+1;i<b;i++) { if(f[i-1]=='A'&&f[i-a]=='A') f[i]='B'; else f[i]='A'; } for(long i=b+1;i<=1000000;i++) { if(f[i-1]=='A'&&f[i-a]=='A'&&f[i-b]=='A') f[i]='B'; else f[i]='A'; } for(long i=1;i<=T;i++) { scanf("%ld",&n); printf("%c",f[n]); } //getch(); }  #### Code mẫu của ll931110 Program MCOINS; Const input = ''; output = ''; Var F: array[-10..1000000] of boolean; n: array[1..50] of longint; k,l,m: longint; Procedure init; Var fi: text; i: longint; Begin Assign(fi, input); Reset(fi); Readln(fi, k, l, m); For i:= 1 to m do read(fi, n[i]); Close(fi); End; Procedure optimize; Var i: longint; Begin For i:= -10 to -1 do F[i]:= true; F[0]:= false; For i:= 1 to 1000000 do F[i]:= not F[i - 1] or not F[i - k] or not F[i - l]; End; Procedure solve; Var fo: text; i: longint; Begin Assign(fo, output); Rewrite(fo); For i:= 1 to m do if F[n[i]] then write(fo, 'A') else write(fo, 'B'); Close(fo); End; Begin init; optimize; solve; End.  #### Code mẫu của khuc_tuan // {$APPTYPE CONSOLE}
{\$mode delphi}

var
f : array[1..3] of integer;
g : array[0..1000000] of boolean;
ok : boolean;
n, i, j : integer;
begin
f[1] := 1;
g[0] := true;
for i:=1 to 1000000 do
begin
ok := false;
for j:=1 to 3 do
if (i >= f[j]) and (g[i-f[j]]) then
ok := true;
g[i] := not ok;
end;
for i:=1 to n do
begin