Nộp bài  Các bài nộp  Làm tốt nhất  Về danh sách bài 
MCOINS  Coins Game 
English  Vietnamese 
Asen and Boyan are playing the following game. They choose two different positive integers K and L, and start the game with a tower of N coins. Asen always plays first, Boyan – second, after that – Asen again, then Boyan, and so on. The boy in turn can take 1, K or L coins from the tower. The winner is the boy, who takes the last coin (or coins). After a long, long playing, Asen realizes that there are cases in which he could win, no matter how Boyan plays. And in all other cases Boyan being careful can win, no matter how Asen plays.
So, before the start of the game Asen is eager to know what game case they have. Write a program coins which help Asen to predict the game result for given K, L and N.
INPUT
The input describes m games.
The first line of the standard input contains the integers K, L and m, 1 < K < L < 10, 3 < m < 50. The second line contains m integers N1, N2, …, Nm, 1 ≤ Ni ≤ 1 000 000, i = 1, 2, …., m, representing the number of coins in each of the m towers
SAMPLE INPUT
2 3 5
3 12 113 25714 88888
OUTPUT
The standard output contains a string of length m composed of letters A and B. If Asen wins the ith game (no matter how the opponent plays), the ith letter of the string has to be A. When Boyan wins the ith game (no matter how Asen plays), the ith letter of the string has to be B.
SAMPLE OUTPUT
ABAAB
Problem for kid  Please, think like kid.
Được gửi lên bởi:  psetter 
Ngày:  20090217 
Thời gian chạy:  1s 
Giới hạn mã nguồn:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Ngôn ngữ cho phép:  Tất cả ngoại trừ: ERL GOSU JSRHINO NODEJS PERL6 PYPY RUST SED VB.NET 
Nguồn bài:  BOI For Kid 08 
hide comments


20210527 18:01:44
Tham khảo: https://vnspoj.github.io/problems/MCOINS 

20200328 16:00:12
. Last edit: 20200329 03:09:14 

20190709 16:06:13
dễ thật, think like kid :D 

20180520 17:57:52
Ai có lời giải cụ thể bài này k zạ 

20170424 20:24:06 Sơn Tùng MTP
Gợi ý quá lố rồi :) 

20161018 17:37:51
Problem for kid  Please, think like kid. :))) 

20150414 15:35:42 Phong
code bừa ac đhs... 

20141116 16:56:31 dark hunter
độ phức tạp có 1000000 mà sao ko AC nhỉ :'( 

20140713 13:11:46 Tuấn IGaMing
Bài cho kid mà mãi vs AC.nhục 

20140428 15:29:56 Nắng
O(maxN) ko AC mới ảo _ 