CF1575C.Cyclic Sum

NOI/NOI+/CTSC

通过率:0%

时间限制:3.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Denote a cyclic sequence of size nn as an array ss such that sns_n is adjacent to s1s_1. The segment s[r,l]s[r, l] where l<rl \lt r is the concatenation of s[r,n]s[r, n] and s[1,l]s[1, l].

You are given an array aa consisting of nn integers. Define bb as the cyclic sequence obtained from concatenating mm copies of aa. Note that bb has size n⋅mn \cdot m.

You are given an integer kk where k=1k = 1 or kk is a prime number. Find the number of different segments in bb where the sum of elements in the segment is divisible by kk.

Two segments are considered different if the set of indices of the segments are different. For example, when n=3n = 3 and m=2m = 2, the set of indices for segment s[2,5]s[2, 5] is 2,3,4,5{2, 3, 4, 5}, and for segment s[5,2]s[5, 2] is 5,6,1,2{5, 6, 1, 2}. In particular, the segments s[1,6],s[2,1],…,s[6,5]s[1, 6], s[2,1], \ldots, s[6, 5] are considered as the same segment.

Output the answer modulo 109+710^9 + 7.

将长度为 nn 的循环序列定义为数组 ss,其中 sns_n 与 s1s_1 相邻。当 l<rl < r 时,区间 s[r,l]s[r, l] 表示 s[r,n]s[r, n] 与 s[1,l]s[1, l] 的拼接。

给定一个由 nn 个整数组成的数组 aa。定义 bb 为将 aa 重复 mm 次后得到的循环序列。注意,bb 的长度为 n⋅mn \cdot m。

给定一个整数 kk,满足 k=1k = 1 或 kk 为质数。求 bb 中满足区间内元素之和能被 kk 整除的不同区间的个数。

若两个区间的下标集合不同,则认为它们是不同的区间。例如,当 n=3n = 3 且 m=2m = 2 时,区间 s[2,5]s[2, 5] 的下标集合为 {2,3,4,5}\{2, 3, 4, 5\},而区间 s[5,2]s[5, 2] 的下标集合为 {5,6,1,2}\{5, 6, 1, 2\}。特别地,区间 s[1,6],s[2,1],…,s[6,5]s[1, 6], s[2,1], \ldots, s[6, 5] 被视为同一个区间。

输出答案对 109+710^9 + 7 取模的结果。

输入格式

The first line contains three integers nn, mm, and kk (1≤n,m,k≤2⋅1051 \leq n, m, k \leq 2 \cdot 10^5, k=1k = 1 or kk is a prime number).

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (0≤ai≤2⋅1050 \leq a_i \leq 2 \cdot 10^5).

第一行包含三个整数 nn、mm 和 kk(1≤n,m,k≤2⋅1051 \leq n, m, k \leq 2 \cdot 10^5,且 k=1k = 1 或 kk 为质数)。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(0≤ai≤2⋅1050 \leq a_i \leq 2 \cdot 10^5)。

输出格式

Output an integer denoting the number of different segments in bb where the sum of elements in the segment is divisible by kk, modulo 109+710^9 + 7.

输出一个整数,表示数组 bb 中有多少个不同的子段,其元素之和能被 kk 整除,结果对 109+710^9 + 7 取模。

输入输出样例

  • 输入#1

    5 1 5
    1 2 3 4 3

    输出#1

    4
  • 输入#2

    5 1 5
    1 2 3 4 5

    输出#2

    5
  • 输入#3

    5 4 5
    1 2 3 4 5

    输出#3

    125

说明/提示

In the first example, all valid segments are [1,4][1,4], [2,3][2, 3], [3,5][3, 5], and [4,2][4, 2].

In the second example, one of the valid segments is [1,5][1, 5].

在第一个例子中,所有有效的区间为 [1,4][1,4]、[2,3][2, 3]、[3,5][3, 5] 和 [4,2][4, 2]。

在第二个例子中,一个有效的区间是 [1,5][1, 5]。

输入解题思路,AI测评打分。不知道怎么写?

首页