#P3232. 「POI2019 R1」Najmniejsza wspólna wielokrotność

「POI2019 R1」Najmniejsza wspólna wielokrotność

Description

Source Problem: POI XXVII - I etap (Najmniejsza wspólna wielokrotność)

Byteasar is studying for a maths test which will focus on determining the least common multiple. Recall that the least common multiple (lcm) of integers a1,,aka_1, \ldots, a_k is the least positive integer d such that each of a1,,aka_1, \ldots, a_k is its divisor. For example, lcm(8,12)=24\mathrm{lcm}(8, 12) = 24, whereas lcm(2,3,4)=12\mathrm{lcm}(2, 3, 4) = 12.

Byteasar quickly mastered the standard exercises, and found the subject so amusing that he started inventing tasks of his own. Let us find out if you are able to solve one of those.

For a given positive integer MM you are to return an interval of positive integers [a,b][a, b] such that the least common multiple of all the integers in it is exactly MM. The interval [a,b][a, b] has to contain at least two positive integers.

To thoroughly test your skills, Byteasar will ask you (or rather your program) multiple queries.

Input Format

In the first input line there is a single integer zz which specifies the number of Byteasar’s queries. The next zz lines specify the queries, one per line. Each query is specified by a single integer MM.

Output Format

Your program should print exactly zz lines to the standard output. The ii-th of these should contain the answer to the ii-th Byteasar’s query. An answer to a query consists of two positive integers aa and bb, separated by a single space, which stand for the interval of integers [a,b][a, b].

If no interval satisfies the desired property, the single word NIE (Polish for no) should be printed instead of any numbers.

If there is more than one answer, report the one with minimum aa, breaking ties (if any) in favor of smaller bb.

3
12
504
17
1 4
6 9
NIE

Additional Samples

See files nww/nww*.in and nww/nww*.out for additional samples.

Additional Sample 1: five MM values: 55, 66, 77, 88, and 99, Additional Sample 2: single MM value: 1 000 0001~000~000, Additional Sample 3: single MM value: 99 999 990 000 00099~999~990~000~000, Additional Sample 4: z=10 000z = 10~000, the values of MM alternate between 500 001 500 001 000 001500~001~500~001~000~001 and 500 001 500 001 000 000500~001~500~001~000~000.

Constraints

Subtask # Additional Constraints Score
11 1z10,1M10001 \le z \le 10, 1 \le M \le 1000 1818
22 1z100,1M1091 \le z \le 100, 1 \le M \le 10^9 2020
33 1z100,1M10181 \le z \le 100, 1 \le M \le 10^{18}
44 1z10000,1M10181 \le z \le 10000, 1 \le M \le 10^{18} 4242