Editorial for LKP '18 Contest 2 P2 - Secret Signal
                Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
                Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Let .
Notice that the sum of a subarray  will be divisible by 
 if 
. Thus we can store a counter array 
 of size 
 such that the 
th entry is the number of prefix sums that are congruent to 
 mod 
. Thus we can just loop through 
, and add 
 to our answer, and then increment it by one.
Time Complexity: 
Comments