codeforces-scrape

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

2043B.md (1048B)


      1 Source: https://codeforces.com/problemset/problem/2043/B
      2 
      3 B. Digits
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Artem wrote the digit $d$ on the board exactly $n!$ times in a row. So, he got the number $dddddd \dots ddd$ (exactly $n!$ digits).
     22 
     23 Now he is curious about which odd digits from $1$ to $9$ divide the number written on the board.
     24 
     25 Input
     26 
     27 The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The next $t$ test cases follow.
     28 
     29 Each test case consists of a single line containing two integers $n$ and $d$ ($2 \le n \le 10^9$, $1 \le d \le 9$).
     30 
     31 Output
     32 
     33 For each test case, output the odd digits in ascending order that divide the number written on the board.
     34 
     35 Example
     36 
     37 Input
     38 
     39 ```
     40 3
     41 
     42 2 6
     43 
     44 7 1
     45 
     46 8 5
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 1 3 
     53 1 3 7 9 
     54 1 3 5 7 9
     55 ```
     56 
     57 Note
     58 
     59 The factorial of a positive integer $n$ ($n!$) is the product of all integers from $1$ to $n$. For example, the factorial of $5$ is $1 \cdot 2 \cdot 3 \cdot 4 \cdot 5 = 120$.