Sign in
or
Register
Courses
Textbook
Compiler
Contests
Topics
Courses
Подготовка к ЕГЭ
USE-2022. Question 27
Module:
USE-2022. Question 27
Problem
3
/11
Subsequence length
Theory
Click to read/hide
Subsequence length
If the subsequence starts with the first element, then its length is equal to the
number
of the last number read (if the first element has the number 1).
Problem
Given a sequence of
N
natural numbers. All its continuous subsequences starting from the first element of the sequence are considered. Find the maximum length of a subsequence with the sum of elements divisible by
K
. The length of a subsequence is equal to the number of elements in it.
Input
The first line contains two numbers: the number of numbers in the sequence
N
(1 <= N <= 10
8
) and the number
K
( 1 <= K <= 100). Next comes
N
lines, one natural number per line. Each number does not exceed
10000
.
Imprint
Print one number on the screen - the number of elements in the found subsequence.
Examples
#
Input
Output
1
5 3
33
41
19
22
40
3
1500
ms
256 Mb
Rules for program design and list of errors in automatic problem checking
Teacher commentary