当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7165:Divide the Sweets

题目描述
To celebrate Children's Day, a mother of $k$ kids comes to the shop to buy sweets. There are $n$ boxes of sweets in the shop, the $i$-th box has $w_i$ sweets. The mother will choose which boxes to buy, and will divide all the bought boxes among the $k$ kids. Each kid will receive several (maybe zero) boxes, and will count the total number of sweets he receives. Assume the $i$-th kid receives $c_i$ sweets, the unfairness is defined as $\sum_{i=1}^k c_i^2$. To make all the kids happy, the mother will always divide boxes to minimize the unfairness. Note that she can not open any box to adjust the number of sweets inside it.

The mother is wondering which boxes to buy. She can not make her final decision. Please write a program to help the mother try all possible $2^n-1$ non-empty subsets of boxes to buy, and figure out the minimum unfairness for each subset. Note that you only need to report the sum of the minimum unfairness among all $2^n-1$ non-empty subsets.
输入解释
The first line contains a single integer $T$ ($1 \leq T \leq 50$), the number of test cases. For each test case:

The first line contains two integers $n$ and $m$ ($1 \leq m\leq n \leq 20$, $n+m\leq 23$), denoting the number of boxes and the parameter $m$.

The second line contains $n$ integers $w_1,w_2,\dots,w_n$ ($1\leq w_i\leq 50\,000$), denoting the number of sweets in each box.

It is guaranteed that there are at most $2$ cases such that $n>12$.
输出解释
For each test case, output $m$ lines, the $i$-th ($1\leq i\leq m$) of which containing an integer, denoting the answer when $k=i$. Note that the answer may be extremely large, so please print it modulo $998\,244\,353$ instead.
输入样例
1
5 4
1 2 3 4 5
输出样例
2240
1180
930
884

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7165

最后修改于 2022-09-15T06:17:08+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
16000/16000MS(Java/Others) 524288/524288K(Java/Others)