## Task 2

In a mathematics competition, 12 participants are from Varaždin, 8 from Zadar, and 2 from Osijek. They need to form a five-member team in which there will be at least one student from each of these three cities, but there cannot be three students from the same city. In how many different ways can they form the team?
## Solution.

The team can consist of

- one student from Varaždin, two from Zadar, and two from Osijek (VZZOO)
- two students from Varaždin, one from Zadar, and two from Osijek (VVZOO)
- two students from Varaždin and Zadar, and one from Osijek (VVZZO).

In the first two cases, both Osijek students are in the team.

In the first case, one Varaždin student can be chosen in 12 ways, and two Zadar students can be chosen in $\frac{8 \cdot 7}{2}=28$ ways. The total number of teams of type "VZZOO" is $12 \cdot 28=336$.

In the second case, a pair of Varaždin students can be chosen in $\frac{12 \cdot 11}{2}=66$ ways, and one Zadar student in 8 ways. The total number of teams of type "VVZOO" is $66 \cdot 8=528$.

Finally, in the third case, two Varaždin students can be chosen in 66 ways, two Zadar students in 28 ways, and one Osijek student in 2 ways, so the total number of teams of type "VVZZO" is $66 \cdot 28 \cdot 2=3696$.

The team can be selected in $336+528+3696=4560$ ways.