report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Divisible by d - MarisaOJ: Marisa Online Judge

Divisible by d

Time limit: 1000 ms
Memory limit: 256 MB
You are given an integers array $A$ of $n$ elements. Count the number of subarray with sum divisible by $d$. A subarray is a contiguous sequence of elements within an array. For example, given an array $B = [1, 2, 3, 4, 5]$, array C = $[2, 3, 4]$ is a subarray of $B$. ### Input - The first line contains 2 integers $n, d$. - The second line contains $n$ integers $A_i$. ### Output - Print the number of subarray with sum divisible by $d$. ### Constraints - $1 \le n, d \le 10^5$. - $|A_i| \le 10^9$. ### Example Input: ``` 5 4 1 3 -2 3 -5 ``` Output: ``` 4 ```
Introduction to Prefix sum
Prefix sum
Maximum subarray sum
Balance substring
Divisible by d
Subarray sum
Game on array
2D prefix sum
Stair query
Maximum sum subarray 2
Average
Ratio Substrings
Maximum submatrix sum
Maximum subarray sum 3
Manhattan distance
Minimum distance
Topic
Prefix sum
Rating 800
Solution (1) Solution