2093C.md (1740B)
1 Source: https://codeforces.com/problemset/problem/2093/C 2 3 C. Simple Repetition 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 Pasha loves prime numbers$^{\text{∗}}$! Once again, in his attempts to find a new way to generate prime numbers, he became interested in an algorithm he found on the internet: 22 23 * To obtain a new number $y$, repeat $k$ times the decimal representation of the number $x$ (without leading zeros). 24 25 For example, for $x = 52$ and $k = 3$, we get $y = 525252$, and for $x = 6$ and $k = 7$, we get $y = 6666666$. 26 27 Pasha really wants the resulting number $y$ to be prime, but he doesn't yet know how to check the primality of numbers generated by this algorithm. Help Pasha and tell him whether $y$ is prime! 28 29 $^{\text{∗}}$An integer $x$ is considered prime if it has exactly $2$ distinct divisors: $1$ and $x$. For example, $13$ is prime because it has only $2$ divisors: $1$ and $13$. Note that the number $1$ is not prime, as it has only one divisor. 30 31 Input 32 33 Each test consists of several sets of input data. The first line contains a single integer $t$ ($1 \leq t \leq 100$) — the number of sets of input data. The following lines describe the sets of input data. 34 35 The first and only line of each data set contains two integers: $x$ and $k$ ($1 \leq x \leq 10^9$, $1 \leq k \leq 7$). 36 37 Output 38 39 For each set of input data, output «YES» (without quotes) if the resulting number $y$ will be prime, and «NO» otherwise. 40 41 You may output «Yes» and «No» in any case (for example, the strings «yES», «yes», and «Yes» will be recognized as positive answers). 42 43 Example 44 45 Input 46 47 ``` 48 4 49 50 52 3 51 52 6 7 53 54 7 1 55 56 1 7 57 ``` 58 59 Output 60 61 ``` 62 NO 63 NO 64 YES 65 NO 66 ```