Strange Number | CodeChef

please tell me the reason that if the number of prime factors of x is greater then k, then why does at-least a number exist so that it has exactly x divisors and exactly k of them are prime?

Let us consider the number A.

How many prime factors does it have?

If A can be written as p_1^{a_1}p_2^{a_2}p_3^{a_3} \dots, It will have (a_1+1)(a_2+1)(a_3 + 1)\dots factors.

Why is that?

For each prime in a factor, It’s power must be less than or equal to the prime’s power in A, Otherwise It won’t be a factor.

So the power of prime p_1, can be anything from 0 to a_1, giving us (a_1+1) choices.p_i itself is not important.

We can choose the power for each prime independently, thus multiplying all of them.

Remember, a number is uniquely determined by it’s prime factors, So there is no double counting.

For each prime factor in A, a_i + 1 is at least 2.

Let’s assume for a second we want to find the maximum K. Since X=(a_1+1)(a_2 + 1)(a_3 + 1)..., It will be optimal to have each of them be a prime factor, Because if it wasn’t, We could split it into 2 numbers both greater than 2, Thus increasing K.

So our maximum K, is just the number of prime factors in X. If we want to make it lesser, we can just merge two factors, Reducing K by 1. So K can take all values less than it’s maximum. Therefore it’s true is the number of prime factors of X is greater than or equal to K

1 Like

Thank you, everule1