0% found this document useful (0 votes)
19 views2 pages

Problem - 1647D - Codeforces

Uploaded by

yhlasyklymov08
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)
19 views2 pages

Problem - 1647D - Codeforces

Uploaded by

yhlasyklymov08
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/ 2

2/20/24, 9:36 PM Problem - 1647D - Codeforces

|
stdfloat | Logout

HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP

PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST

Codeforces Round 777 (Div. 2)


D. Madoka and the Best School in Russia Finished
time limit per test: 2 seconds
Practice
memory limit per test: 256 megabytes
input: standard input
output: standard output

Madoka is going to enroll in "TSUNS PTU". But she stumbled upon a difficult task during the → Virtual participation 
entrance computer science exam:

A number is called good if it is a multiple of d . → Clone Contest to Mashup 


A number is called beatiful if it is good and it cannot be represented as a product of two
good numbers. → Submit?
Notice that a beautiful number must be good.
Language: GNU G++20 11.2.0 (64 bit, w
Given a good number x , determine whether it can be represented in at least two different
Choose
ways as a product of several (possibly, one) beautiful numbers. Two ways are different if the Choose File No file chosen
file:
sets of numbers used are different.
Submit
Solve this problem for Madoka and help her to enroll in the best school in Russia!

Input → Contest materials


The first line contains a single integer t (1 ≤ t ≤ 100 ) — number of test cases. Below comes
their description.
Announcement

Each test case consists of two integers x and d , separated by a space (2 ≤ x, d ≤ 10


9
). It is Tutorial
guaranteed that x is a multiple of d .

Output
For each set of input data, output "NO" if the number cannot be represented in at least two
ways. Otherwise, output "YES".

You can output each letter in any case (for example, "YES", "Yes", "yes", "yEs", "yEs" will
be recognized as a positive answer).

Example
input Copy

8
6 2
12 2
36 2
8 2
1000 10
2376 6
128 4
16384 4

output Copy

NO
NO
YES
NO
YES
YES
NO
YES

https://codeforces.com/problemset/problem/1647/D 1/2
2/20/24, 9:36 PM Problem - 1647D - Codeforces
Note
In the first example, 6 can be represented as 6, 1 ⋅ 6 , 2 ⋅ 3 . But 3 and 1 are not a good
numbers because they are not divisible by 2, so there is only one way.

In the second example, 12 can be represented as 6 ⋅ 2 , 12 , 3 ⋅ 4 , or 3 ⋅ 2 ⋅ 2 . The first option


is suitable. The second is— no, because 12 is not beautiful number (12 = 6 ⋅ 2 ). The third
and fourth are also not suitable, because 3 is not good number.

In the third example, 36 can be represented as 18 ⋅ 2 and 6 ⋅ 6 . Therefore it can be


decomposed in at least two ways.

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: Feb/20/2024 21:18:21UTC+5 (f1).
Desktop version, switch to mobile version.
Privacy Policy

Supported by

https://codeforces.com/problemset/problem/1647/D 2/2

You might also like