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

建议使用的浏览器:

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

6794:Tokitsukaze and Multiple

题目描述
Tokitsukaze has a sequence of length $n$, denoted by $a$.

Tokitsukaze can merge two consecutive elements of $a$ as many times as she wants. After each operation, a new element that equals to the sum of the two old elements will replace them, and thus the length of $a$ will be reduced by $1$.

Tokitsukaze wants to know the maximum possible number of elements that are multiples of $p$ she can get after doing some operations (or doing nothing) on the sequence $a$.
输入解释
There are several test cases.

The first line contains an integer $T$ $(1 \leq T \leq 20)$, denoting the number of test cases. Then follow all the test cases.

For each test case, the first line contains two integers $n$ and $p$ $(1 \leq n, p \leq 10^5)$, denoting the length of the sequence and the special number, respectively.

The second line contains $n$ integers, where the $i$-th integer $a_i$ $(1 \leq a_i \leq 10^5)$ is the $i$-th element of $a$.

It is guaranteed that the sum of $n$ in all test cases is no larger than $10^6$.
输出解释
For each test case, output in one line the maximum possible number of elements that are multiples of $p$ after doing some operations.
输入样例
2
5 3
2 1 3 2 1
3 1
123 456 789
输出样例
3
3
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6794

最后修改于 2020-10-25T23:34:26+00:00 由爬虫自动更新

共提交 0

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