#K53182. Continuous Subarray Multiple Sum
Continuous Subarray Multiple Sum
Continuous Subarray Multiple Sum
You are given a list of integers and an integer k. Your task is to determine whether there exists a continuous subarray of at least length 2 whose sum is a multiple of k. In other words, if the subarray's sum is S, then there should exist an integer n such that:
\( S = n\times k \)
If k is 0, you need to check if there exists a continuous subarray of at least length 2 that sums exactly to 0.
The subarray must consist of consecutive elements from the original list.
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains two integers n and k, where n is the number of elements in the list.
- The second line contains n space-separated integers representing the array.
outputFormat
Output a single line to stdout containing either True
or False
depending on whether such a subarray exists.
5 6
23 2 4 6 7
True