MCOINS - Coins Game

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:2009-02-17
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 JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:BOI For Kid 08

hide comments
2021-05-27 18:01:44
Tham khảo: https://vnspoj.github.io/problems/MCOINS
2020-03-28 16:00:12
.


Last edit: 2020-03-29 03:09:14
2019-07-09 16:06:13
dễ thật, think like kid :D
2018-05-20 17:57:52
Ai có lời giải cụ thể bài này k zạ
2017-04-24 20:24:06 Sơn Tùng M-TP
Gợi ý quá lố rồi :)
2016-10-18 17:37:51
Problem for kid - Please, think like kid. :)))
2015-04-14 15:35:42 Phong
code bừa ac đhs...
2014-11-16 16:56:31 dark hunter
độ phức tạp có 1000000 mà sao ko AC nhỉ :'(
2014-07-13 13:11:46 Tuấn IGaMing
Bài cho kid mà mãi vs AC.nhục
2014-04-28 15:29:56 Nắng
O(maxN) ko AC mới ảo -_-
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.