[CSP-S 2019] D2T1 Emiya family meal today

Description

Portal

Solution

Algorithm 1

Burst search complexity \ (O ((m + 1 ) ^ n) \)

Algorithm 2

Bare dp, the complexity of the \ (O (n ^ 3m) \)

First, there is a clear that the nature of the need to know:

At most only one main ingredient found in more than half of the main ingredients in.

Next, consider if only the first two constraints of the situation, the answer is

\[\Pi_{i=1}^{n} (sum_i+1) - 1\]

Wherein \ (sum_i = \ SUM \ limits_ {J =. 1} ^ m A_ {I, J} \) , \ (+. 1 \) because for each row is only selected from the dish or not choose these options, \ (--1 \) is to remove the case because a dish is not selected.

Guess you like

Origin www.cnblogs.com/newbielyx/p/11891960.html