GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Sunday 2 October 2022

[Solution] Equivalent Numbers CodeChef Solution



Problem

Chef calls a pair of integers (A, B) equivalent if there exist some positive integers X and Y such that A^X = B^Y.

Given A and B, determine whether the pair is equivalent or not.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of two space-separated integers A and B, as mentioned in statement.

Output Format

For each test case, output YES if (A, B) is an equivalent pair, NO otherwise.

The output is case-insensitive. Thus, the strings YesYESyes, and yeS are all considered identical.

Explanation:

Test case 1: There are no positive integers X and Y which satisfy A^X = B^Y.

Test case 2: Let X = 2 and Y = 3. Thus, A^X = 8^2 = 64 and B^Y = 4^3 = 64. Thus, the pair (8, 4) is equivalent.

Test case 3: There are no positive integers X and Y which satisfy A^X = B^Y.

No comments:

Post a Comment