2241B.md (1401B)
1 Source: https://codeforces.com/problemset/problem/2241/B 2 3 B. Good times Good times 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 An integer $n$ is said to be good if it contains at most two distinct digits in its decimal representation. For example, the integers $3$, $8588$, $67$ are good, whereas the integers $123$, $9447$ are not. 22 23 You are given an integer $x$ ($1 \le x \lt 10^8$), which is good. Your task is to find an integer $y$ ($2 \le y \le 10^9$) such that both of the following conditions are satisfied: 24 25 * $y$ is good. 26 * $x \times y$ is good. 27 28 Input 29 30 The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases. The description of each test case follows. 31 32 Each test case contains a single integer $x$ ($1 \le x \lt 10^8$). It is guaranteed that $x$ is good. 33 34 Output 35 36 For each test case, print a single integer $y$ ($2 \le y \le 10^9$) such that both the integers $y$ and $x \times y$ are good. 37 38 If there are multiple valid answers, output any one of them. 39 40 Example 41 42 Input 43 44 ``` 45 4 46 47 8 48 49 73 50 51 299 52 53 6767 54 ``` 55 56 Output 57 58 ``` 59 11 60 4 61 26 62 3366 63 ``` 64 65 Note 66 67 For the first test case, we have $x = 8$; choosing $y = 11$ is valid because both $y = 11$ and $x \times y = 88$ are good. 68 69 For the second test case, we have $x = 73$; choosing $y = 4$ is valid because both $y = 4$ and $x \times y = 292$ are good.