N has at most six distinct prime divisors; count the sequences of divisors greater than 1 where each new divisor shares a factor with at most one earlier entry, modulo 1e9+7.
Hard8CombinatoricsMathNumber theoryDynamic programmingNo attempts yetTime limit2sMemory limit512 MBElly studies the properties of an integer N. So far she has found that it has no more than six distinct prime divisors. A prime is a natural number greater than 1 that has no positive divisors other than 1 and itself.
Elly now spends her time like this. Starting from an empty list, she writes divisors of N that are greater than 1, and she may repeat the same divisor several times. When she adds a new number, she makes sure that it has a common divisor greater than 1 with at most one of the numbers already written.
For example, if N=12156144, then (42), (616, 6, 91, 23), (91, 616, 6, 23), (66, 7), (66, 7, 7, 23, 299, 66), (143, 13, 66) and (42, 12156144) are lists Elly can produce. The list (5, 11) is invalid because 5 is not a divisor of 12156144, and the list (66, 13, 143) is invalid because 143 has a common divisor greater than 1 with both 13 and 66.
Count the valid lists Elly can write. Two lists are different if they have different lengths, or if some position holds a different number. Elly writes at least one number, so the empty list is not counted.
The first line of standard input contains one integer N.
Print on standard output one integer, the number of different lists Elly could have written, modulo 1000000007.
For N=6 the 28 valid lists are:
{(2), (2, 2), (2, 2, 3), (2, 2, 3, 3), (2, 3), (2, 3, 2), (2, 3, 2, 3), (2, 3, 3), (2, 3, 3, 2), (2, 6), (2, 6, 3), (3), (3, 2), (3, 2, 2), (3, 2, 2, 3), (3, 2, 3), (3, 2, 3, 2), (3, 3), (3, 3, 2), (3, 3, 2, 2), (3, 6), (3, 6, 2), (6), (6, 2), (6, 2, 3), (6, 3), (6, 3, 2), (6, 6)}
For N=12156144 the number of lists is 14104757650, so the answer modulo 1000000007 is 104757552.