Partitions
Time limit2sMemory limit512 MB
Find the smallest set of distinct positive integers with exactly k splits where one part's LCM equals the other part's GCD, given as prime factorizations.
- Level
Hard9 of 10
- Topics
- Number theory, Combinatorics, Math
- Solved
- No attempts yet
Problem
Brian has found the Legendary Set of Numbers, a fabled set of positive integers said to have mysterious properties. Being a very kind person, he decides to share the set with his two closest friends, Abhilash and Kevin. He has known them for a long time, and they squabble at the least provocation, so he needs to split the set in an equitable way.
Abhilash loves the LCM, or least common multiple. The LCM of a set is the smallest positive integer divisible by all of its elements. Kevin loves the GCD, or greatest common divisor. The GCD of a set is the largest positive integer that divides all of its elements.
Brian wants to partition the set into two parts such that the LCM of the part given to Abhilash equals the GCD of the part given to Kevin. He quickly finds such a partition in the Legendary Set of Numbers. Playing around more, he realizes there are exactly ways to do so!
Brian thinks this is no coincidence, since this is the Legendary Set of Numbers. He wonders whether it is the smallest set with exactly partitions where the LCM of one part is the GCD of the other. He also asks about other counts. Specifically, what is the smallest such that some set of distinct positive integers can be partitioned in exactly ways where the LCM of one part is the GCD of the other?
Brian also asks you to supply such a set as proof. Since the numbers may get large, give each one as its prime factorization, with the numbers in sorted increasing order.
A partition of a set is a pair of nonempty sets and with , , , and . For , the smallest set is . Its only partition is and , where the LCM of and the GCD of are both .
Input
The input is a single line containing one integer ().
Output
Output one line with the integer , the smallest size of a set as described above.
Then output lines. The th line describes the th smallest number in the set. Each line has the form , where adjacent numbers are separated by a space. Here is the number of distinct prime factors of the number, and for , is a prime factor and is its multiplicity. The values must satisfy , , and .