in problem 27E you are asked to find the smallest positive integer which has exactly n divisors .
how to solve it > >
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
in problem 27E you are asked to find the smallest positive integer which has exactly n divisors .
how to solve it > >
Название |
---|
We denote the number of divisors of a number x, as d(x). It can be proven that d(x) = (e1 + 1)·(e2 + 1)·...·(ek + 1) , where x = p1e1·p2e2·...·pkek is the prime factorization of x.
We notice that it's optimal for p1 to be as small as it can be, so it should be equal to 2. We notice the same for p2, so it should be equal to 3. It is optimal to take the smallest possible prime every time. So we should only take the first k primes. But consider the case where ei = 1 i. We see that if we take more than pk = 41 (approximately), we are way over our limit of 1018 for our answer. So our list of primes should be up to 41.
Now we try to construct the desired number by some kind of trial-and-error. As long as we can multiply our current number with the current prime raised to some power ei, we test for this situation, going to the next prime, knowing the current number's divisors and its value. Notice that every prime should not fit more than times in some number X, and we only have about 15 primes, so operations aren't too much.
Solution link: 43224863
thanks.. charis .. i got it...
trying every possibility in brute force way to get the minimum number...
ur solution is very clear... :))
You can bring down the operations even more, considering the fact that e(i)>=e(i+1) in the optimal solution.
Yes, you are right. Holding an extra parameter for ei - 1 and starting ei from there instead of 1. I believe you can also use dp on this idea if you modify it a little, but I don't think it's necessary.
Fun fact: You missed 23 in your list of primes Luckily it didn't affect the solutions in this case :p