#C4163. Contiguous Subsequence Sum Finder
Contiguous Subsequence Sum Finder
Contiguous Subsequence Sum Finder
Given an array \(a\) of length \(n\) and a target integer \(S\), determine whether there exists a contiguous subsequence (subarray) whose sum equals \(S\). In other words, find indices \(l\) and \(r\) with \(1 \le l \le r \le n\) such that
[ \sum_{i=l}^{r} a_i = S, ]
For each test case, output Sub-sequence found.
if such a subsequence exists, otherwise output No sub-sequence found.
inputFormat
The input is read from stdin and is formatted as follows:
- The first line contains an integer \(T\), the number of test cases.
- For each test case, there are three lines:
- The first line contains an integer \(N\), the number of elements in the array.
- The second line contains \(N\) space-separated integers representing the array.
- The third line contains an integer \(S\), the target sum.
outputFormat
For each test case, print a single line to stdout containing either Sub-sequence found.
if a contiguous subsequence with sum equal to \(S\) exists, or No sub-sequence found.
otherwise.
2
5
1 2 3 4 5
9
4
-1 2 3 -4
1
Sub-sequence found.
Sub-sequence found.
</p>