22:45 8/4/25 Problem - C - Codeforces
|
QuanVanHoang | Logout
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN
PROBLEMS SUBMIT CODE MY SUBMISSIONS STATUS STANDINGS CUSTOM INVOCATION
Codeforces Round 1016 (Div. 3)
C. Simple Repetition Contest is running
time limit per test: 1 second
01:04:58
memory limit per test: 256 megabytes
Contestant
Pasha loves prime numbers∗ ! 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:
To obtain a new number y, repeat k times the decimal representation of the number x
(without leading zeros). → Submit?
For example, for x = 52 and k = 3, we get y = 525252 , and for x = 6 and k = 7 , we get Language: Python 3.13.2
y = 6666666. Almost always, if you send a solution
on PyPy, it works much faster
Pasha really wants the resulting number y to be prime, but he doesn't yet know how to check the Choose
Chọn tệp Không có …được chọn
file:
primality of numbers generated by this algorithm. Help Pasha and tell him whether y is prime!
Submit
∗
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.
Input
Each test consists of several sets of input data. The first line contains a single integer t (
1 ≤ t ≤ 100 ) — the number of sets of input data. The following lines describe the sets of input
data.
The first and only line of each data set contains two integers: x and k (1
9
≤ x ≤ 10 ,
1 ≤ k ≤ 7 ).
Output
For each set of input data, output «YES» (without quotes) if the resulting number y will be prime,
and «NO» otherwise.
You may output «Yes» and «No» in any case (for example, the strings «yES», «yes», and
«Yes» will be recognized as positive answers).
Example
input Copy
4
52 3
6 7
7 1
1 7
output Copy
NO
NO
YES
NO
Codeforces (c) Copyright 2010-2025 Mike Mirzayanov
The only programming contests Web 2.0 platform
Server time: Apr/08/2025 22:15:21UTC+7 (g1).
Desktop version, switch to mobile version.
Privacy Policy | Terms and Conditions
Supported by
https://codeforces.com/contest/2093/problem/C 1/2