0% found this document useful (0 votes)
17 views

Problem - C - Codeforces

The document describes a problem from Codeforces Round 1016 (Div. 3) where the contestant Pasha needs to determine if a number y, generated by repeating a number x k times, is prime. The input consists of multiple test cases with values for x and k, and the output should be 'YES' if y is prime and 'NO' otherwise. The constraints specify that x can be as large as 10^9 and k can be up to 7.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Problem - C - Codeforces

The document describes a problem from Codeforces Round 1016 (Div. 3) where the contestant Pasha needs to determine if a number y, generated by repeating a number x k times, is prime. The input consists of multiple test cases with values for x and k, and the output should be 'YES' if y is prime and 'NO' otherwise. The constraints specify that x can be as large as 10^9 and k can be up to 7.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy