#K88517. Consecutive Subsequence Divisibility by 10
Consecutive Subsequence Divisibility by 10
Consecutive Subsequence Divisibility by 10
You are given a list of n positive integers. Your task is to determine if there exists a contiguous subsequence of exactly three consecutive elements such that the sum of these three numbers is divisible by 10.
More formally, given an integer \( n \) and an array \( arr \) of \( n \) positive integers, check if there exists an index \( i \) (with \( 0 \le i \le n-3 \)) such that:
[ \text{arr}[i] + \text{arr}[i+1] + \text{arr}[i+2] \equiv 0 ; (\text{mod } 10) ]
If such a subsequence exists, output Yes
otherwise output No
.
Note: A subsequence here refers specifically to three consecutive elements in the list.
inputFormat
The first line of input contains a single integer \( n \) representing the number of elements in the list. The second line contains \( n \) space-separated positive integers representing the list.
outputFormat
Output a single line containing Yes
if there exists a contiguous subsequence of three consecutive elements whose sum is divisible by 10, or No
otherwise.
5
10 15 20 25 30
Yes
</p>