Number Magic
시간 제한3초메모리 제한2048 MB
고정된 시작 수 N에서 현재 자릿수만큼의 1로 이루어진 수를 더하거나 2로 나눈 몫을 취하는 연산을 32번 이하로 써서 각 목표 수 M에 도달할 수 있는지 판정한다.
문제
Alice and Bob engage in a strategic duel called Number Magic, where Alice initially chooses a positive integer called the starting number. The game permits two specific magic operations to be performed on a positive integer :
- Say has digits. One operation is to add the number consisting of -digits (i.e. ) to . For example, if then this magic operation would add to resulting in ; if then it becomes ; if it becomes .
- If , one operation is to divide by and round down. For example, if then it becomes , if it becomes .
There are rounds of the duel. In round , Bob picks a target number and the Alice must determine if it is possible to apply at most magic operations to the starting number in order to reach . That is, Alice should find a sequence with such that and can be obtained by applying a magic operation to for each ? Note, only will change between rounds: will be the same in each round.
This is a very challenging game, Alice has asked you for help!
입력
The first line of input contains two space integers, () and () where is the starting number that Alice chooses and is the number of rounds.
Then lines follow, the ’th such line containing a single integer () indicating the target number that Bob chooses for round .
출력
Output lines where line contains the text YES if it is possible to transform into using at most applications of magic, otherwise line contains the text NO.