[Solution] Prime Factor Division CodeChef Solution
Problem
Mario has reached Bowser's Castle and is inches away from rescuing Princess Peach. He has to answer the following problem at the gate to be allowed to enter. Can you help him?
Let denote the set of all prime factors of .
Given two positive integers and , determine whether is divisible by all elements in .
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of a single line of input, and , as mentioned in the statement.
Output Format
For each test case, print YES
if is divisible by all elements in and NO
otherwise.
You may print each character of the string in uppercase or lowercase (for example, the strings YES
, yEs
, yes
, and yeS
will all be treated as identical).
Explanation:
Test case : The set of all prime factors of is given by . Also, is divisible by all elements in .
Test case : The set of all prime factors of is given by . Also, is divisible by all elements in .
Test case : The set of all prime factors of is given by . Here, is not divisible by in .
No comments:
Post a Comment