Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя Tobby_And_Friends

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

UVA 13085

Problem Name: Forming Teams

Problem link: https://uva.onlinejudge.org/contests/364-bb2339ba/13085.pdf

I understand that for a number n I need to find out all of its divisors and then I need to find out the possible combinations for each divisor. I could not figure out how to come up with the combinations. Any help is really appreciated.

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

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

Please help :'(

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

Hey Fam. Since I have to divide it into equal teams, the first thing that should strike is that I count the divisors in O(sqrt(n)) time and then I can calculate the sum over all them. What I means is that suppose you have two divisors such that d1*d2 = n, you have two choices form d1 groups with d2 elements or vice versa. Suppose I do the former(it'd be obvious for the latter). So I have to select d2 persons from n, then select again d2 persons from n — d2 persons.. so on. So, this would give answer to be (n!)/((d2!)^(d1)). But there's a catch as all the groups are identical, we have to divide it by (d1!) also. So, my answer becomes sum of this over all the divisors. I hope you get it.