#C6638. Contiguous Subarray Sum Divisibility

    ID: 50420 Type: Default 1000ms 256MiB

Contiguous Subarray Sum Divisibility

Contiguous Subarray Sum Divisibility

You are given an array of integers and an integer k. Your task is to determine whether there exists a contiguous subarray of length at least 2 such that the sum of its elements is divisible by \( k \) (i.e. the sum modulo \( k \) equals 0).

Note: The subarray must consist of consecutive elements in the array. If such a subarray exists, print True; otherwise, print False.

Example:

Input:
5 6
23 2 4 6 7

Output: True

</p>

inputFormat

The input is given via standard input (stdin) in the following format:

  • The first line contains two space-separated integers: n (the number of elements in the array) and k (the integer divisor).
  • The second line contains n space-separated integers representing the elements of the array.

outputFormat

Output a single line to standard output (stdout):

  • True if there exists a contiguous subarray of at least two elements whose sum is divisible by k; otherwise, False.
## sample
5 6
23 2 4 6 7
True

</p>