Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.


By forthright48 · Limits 500ms, 512 MB

Given 3 numbers, G, A and B we have to find two numbers M and N such that they satisfy the following conditions:

  • M and N have no other prime divisor except 2 and 3
  • Greatest common divisor of M and N is G
  • Number of divisor of M is A
  • Number of divisor of N is B
  • M is between 1 and 1018
  • N is between 1 and 1018

It is possible that multiple pairs of M and N satisfy the above conditions. In such a case, we want to find the pair where M is minimum. If there is still tie, then we minimize N.

It is guaranteed that a solution always exists.


The first line contains a single integer T (T ≤ 100) denoting number of test case. The next T lines describes each test case. Each test case is a single line containing three integers: G, A and B.


For each test case, output a single line containing two integers: M and N satisfying the conditions mentioned in problem statement above.


1 2 2
6 6 8
2 3
12 54



    39% Solution Ratio

    jackal_1586Earliest, May '16

    rubbyEFastest, 0.0s

    jubair_123Lightest, 131 kB

    AnachorShortest, 791B


    Login to submit