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

Автор bluemmb, 9 лет назад, По-английски

We have N persons numbered from 1 to N. Also there are M identical rooms with infinity capacity.

In how many ways we can distribute persons in rooms such that each room contains at least 1 person ?

Two ways A and B are regarded as the same if for any room in A, there exists a room in B that the persons in these two rooms have the same set of numbers. In other words, rooms are indistinguishable.

for example : 2 rooms , 3 persons , ans = 3 : (1)(2,3) , (2)(1,3) , (3)(1,2)

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

»
9 лет назад, скрыть # |
 
Проголосовать: нравится +21 Проголосовать: не нравится

Pretty sure you're talking about the Stirling numbers of second kind.

»
9 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +31 Проголосовать: не нравится

actually you can use this formula

as you can see it can be written as the product of two polynomials and (k - i)n
so you can easily find s(n, k) for a fixed n and all k.

  • »
    »
    9 лет назад, скрыть # ^ |
    Rev. 3  
    Проголосовать: нравится +10 Проголосовать: не нравится

    thanks... very nice! congratulations for being the only team who solved it ... :)

    I don't know FFT for programming contests yet ... I have to learn it first ... can you suggest a good resource for learning it ?

  • »
    »
    9 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +5 Проголосовать: не нравится

    I was reading your approach and I noticed that is not a 1-D array that you can easily multiply, it's 2-D so it can't be used. What we can do here is to reformat the formula: so you should use and . So if you have two polynomials, one with coefficients and one with coefficients , then k - th coefficient of their product is indeed s(n, k).

    P.S: Nice approach by the way, inclusion-exclusion principle...

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

Each of N persons to any of M rooms minus cases of N persons in M-1 rooms m^n-m*(m-1)^n