# Counting the number of ways to divide into teams - complicated

$$n$$ students are standing in a row. Teacher must divide them into smaller teams - it could be one team or more - (team must consist of students standing next to each other in a row) and choose in every team a team leader. On how many ways he can do it?

I know how to calculate numbers of solution of the equasion

$$x_1 + x_2 + \ldots + x_k = n$$, where $$x_i\in\mathbb{Z}$$ and $$x_i\ge 0$$.

I have no idea how to attack version with team leaders.

• It's just number of arrangements cleared from number of local arrangements in each subset, where number of subsets are the sum of combination from 0 to n from n, it's long and complicated yes with inclusion/exclusion principle. – Abr001am Aug 23 at 0:50

Suppose we have a single team of $$n$$ students. The number of ways to designate a leader is simply $$n$$; so the exponential generating function of the number of ways to designate a leader is $$T(z) = \sum_{n=0}^{\infty} n \cdot \frac{1}{n!} z^n = \sum_{n=1}^{\infty} \frac{1}{(n-1)!} z^n = z e^z$$ The organization of all the students into teams with leaders is the set of all teams with leaders. So its exponential generating function is $$e^{T(z)} = e^{z e^z}$$