Imagine a Graph 1

Tough Dash, September 202...
Limits 1s, 512 MB

Imagine a graph of infinite nodes labelled with positive integers from 1 to \infty.

Take every pair of nodes that are labelled with prime numbers and multiply the two prime numbers. You will get a composite number. Draw an edge between the first prime number and the composite number. Then draw another edge between the second prime number and the composite number.

You will be given two numbers. You have to tell whether there is a path between these two numbers.


The input will contain two integers AA and BB (1A,B1071 \le A, B \le 10^7).


Print “Yes” (w/o quotes) if there is a path between AA and BB. Otherwise, print “No” (w/o quotes).


2 15

There is a path from 2 to 10 to 5 to 15.


Login to submit.


65% Solution Ratio
EgorKulikovEarliest, 2w ago
pathanFastest, 0.0s
pathanLightest, 5.5 MB
Swaccha105085Shortest, 411B
Toph uses cookies. By continuing you agree to our Cookie Policy.