# Thread:

1. ## Place 37 people into 5 rooms so that each room has at least 1 person in it?

I know that if i forget about the condition that no room is empty, then i can line 37 people up and assign each to a room to get a sequence with repetition, which means 5 ways to give the first person a room, 5 ways for the second etc until i get $5^{37}$ possible ways to place 37 people in 5 rooms. But now with the condition that no room is empty? I suppose i could subtract the subcases of 1 room empty,and 37 people in 4 rooms, 2 rooms empty and 37 people in 3 rooms etc, but this seems lengthy and i have a feeling there's a better way?

2. Originally Posted by punkstart
I know that if i forget about the condition that no room is empty, then i can line 37 people up and assign each to a room to get a sequence with repetition, which means 5 ways to give the first person a room, 5 ways for the second etc until i get $5^{37}$ possible ways to place 37 people in 5 rooms. But now with the condition that no room is empty?
This a matter of counting the number of surjections( onto functions) from a set of 37 to a set of 5.
$\text{Surj}(N,K)=\displaystyle\sum\limits_{j = 0}^K {\left( { - 1} \right)^j \binom{K}{j}\left( {K - j} \right)^N }$

Here $N=37~\&~K=5$
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 4, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.959497332572937, "perplexity_flag": "head"}