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

建议使用的浏览器:

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

6984:Tree Planting

题目描述
There are $n$ buildings on the side of Bytestreet, standing sequentially one next to the other, labeled by $1,2,\dots,n$ from east to west. The city planning investigation is going to plant some trees in front of these buildings. A tree planting plan is beautiful if and only if it satisfies all the conditions below:
  • At least one tree is planted.
  • A tree can only be planted in front of a building, and two trees can not be planted in front of the same building. In other words, let $c_i$ denote the number of trees planted in front of the $i$-th building, $c_i\in\{0,1\}$ holds for all $i=1,2,\dots,n$.
  • For every possible value of $i$ ($1\leq i<n$), $c_i$ and $c_{i+1}$ shouldn't both be $1$.
  • For every possible value of $i$ ($1\leq i\leq n-k$), $c_i$ and $c_{i+k}$ shouldn't both be $1$.
The beautifulness of a plan is defined as:\[\prod_{1\leq i\leq n,c_i=1}w_i\]You need to find the sum of beautifulness among all the beautiful plans. Two plans are considered different if there exists any $i$ ($1\leq i\leq n$) such that they differ in $c_i$.
输入解释
The first line contains a single integer $T$ ($1 \leq T \leq 200$), the number of test cases. For each test case:

The first line contains two integers $n$ and $k$ ($2 \leq k<n \leq 300$), denoting the number of buildings and the value of $k$.

The second line contains $n$ integers $w_1,w_2,\dots,w_n$ ($1\leq w_i\leq 10^9$).

It is guaranteed that there will be at most $10$ test cases such that $n>100$.
输出解释
For each test case, output a single line containing an integer, denoting the sum of beautifulness among all the beautiful plans. Note that the answer may be extremely large, so please print it modulo $10^9+7$ instead.
输入样例
2
5 3
1 1 1 1 1
5 4
1 2 3 4 5
输出样例
10
55

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

源链接: HDU-6984

最后修改于 2021-10-23T19:10:54+00:00 由爬虫自动更新

共提交 0

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