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

建议使用的浏览器:

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

3844:Divisible Subsequences

题目描述
Given a sequence of positive integers, count all contiguous subsequences (sometimes called substrings, in contrast to subsequences, which may leave out elements) the sum of which is divisible by a given number. These subsequences may overlap. For example, the sequence (see sample input)
2, 1, 2, 1, 1, 2, 1, 2

contains six contiguous subsequences the sum of which is divisible by four: the first to eighth number, the second to fourth number, the second to seventh number, the third to fifth number, the fourth to sixth number, and the fifth to seventh number.
输入解释
The first line of the input consists of an integer c (1 <= c <= 200), the number of test cases. Then follow two lines per test case.
Each test case starts with a line consisting of two integers d (1 <= d <= 1 000 000) and n (1 <= n <= 50 000), the divisor of the sum of the subsequences and the length of the sequence, respectively. The second line of a test case contains the elements of the sequence, which are integers between 1 and 1 000 000 000, inclusively.
输出解释
For each test case, print a single line consisting of a single integer, the number of contiguous subsequences the sum of which is divisible by d.
输入样例
2
7 3
1 2 3
4 8
2 1 2 1 1 2 1 2
输出样例
0
6

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3844

最后修改于 2020-10-29T07:13:28+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536