codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1478B.md (1286B)


      1 Source: https://codeforces.com/problemset/problem/1478/B
      2 
      3 B. Nezzar and Lucky Number
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 512 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Nezzar's favorite digit among $1,\ldots,9$ is $d$. He calls a positive integer lucky if $d$ occurs at least once in its decimal representation.
     22 
     23 Given $q$ integers $a_1,a_2,\ldots,a_q$, for each $1 \le i \le q$ Nezzar would like to know if $a_i$ can be equal to a sum of several (one or more) lucky numbers.
     24 
     25 Input
     26 
     27 The first line contains a single integer $t$ ($1 \le t \le 9$) — the number of test cases.
     28 
     29 The first line of each test case contains two integers $q$ and $d$ ($1 \le q \le 10^4$, $1 \le d \le 9$).
     30 
     31 The second line of each test case contains $q$ integers $a_1,a_2,\ldots,a_q$ ($1 \le a_i \le 10^9$).
     32 
     33 Output
     34 
     35 For each integer in each test case, print "YES" in a single line if $a_i$ can be equal to a sum of lucky numbers. Otherwise, print "NO".
     36 
     37 You can print letters in any case (upper or lower).
     38 
     39 Example
     40 
     41 Input
     42 
     43 ```
     44 2
     45 3 7
     46 24 25 27
     47 10 7
     48 51 52 53 54 55 56 57 58 59 60
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 YES
     55 NO
     56 YES
     57 YES
     58 YES
     59 NO
     60 YES
     61 YES
     62 YES
     63 YES
     64 YES
     65 YES
     66 NO
     67 ```
     68 
     69 Note
     70 
     71 In the first test case, $24 = 17 + 7$, $27$ itself is a lucky number, $25$ cannot be equal to a sum of lucky numbers.