algorithm to combinatorics
Posted
by peiska
on Stack Overflow
See other posts from Stack Overflow
or by peiska
Published on 2010-06-03T09:48:02Z
Indexed on
2010/06/03
10:14 UTC
Read the original article
Hit count: 561
java
|combinatorics
I am trying to solve a combinatorics problem, it seems easy, but i am having some trouble with it.
If i have at most X tables, and N persons to sit on the tables, Each table can have 1 to N seating places, and I can only sit persons in one side of a rectangular table( so the order how people sit matters).
I want to make a code that can calculate all the distributions of seating places from 1 up to K tables.
For example, if I have 12 persons and 1 table i have 479001600 ways of seating persons( thats easy to calculate I've used Factorial of 12).
But if I have 12 persons and 3 tables i have 4390848000 ways of seating persons. I've tried different solutions but i was not able to find the correct one.
I've tried to divided the 12 in 3, then o use factorial of the result (it didnt work), i've tried to use 12! * 3( it didn't work too).
Can some one give me a tip in a algorithm that i can use?
© Stack Overflow or respective owner