Блог пользователя aka.Sohieb

Автор aka.Sohieb, история, 8 лет назад, По-английски

I was trying to solve this problem 27E - Число с заданным количеством делителей, it was said in the editorials that this is a dynamic programming problem,

but i tried to solve it using only back tracking with pruning and i got AC 19429925.

could anyone tell what is the complexity of this solution?! or how to measure the complexity of bt solutions in general?!

thanks in advance :)

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

1) Look at maximal possible depth of recursion for each divisor. They don't go so deep, and this is upper bound.

Some calculations

2) The main speed-up is if (divs <= n) statement because n <= 1000 and therefore divs cannot be greater than nine, which is reached only when we take each of the divisors once.

In general it's very hard to give some good upper bound for backtracking solutions like that and all you can do is to say: "OK, we have these rough estimates that are not so helpful, let's add some optimisations and hope that this'll give us AC".