#C4163. Contiguous Subsequence Sum Finder

    ID: 47671 Type: Default 1000ms 256MiB

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:
    1. The first line contains an integer \(N\), the number of elements in the array.
    2. The second line contains \(N\) space-separated integers representing the array.
    3. 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.

## sample
2
5
1 2 3 4 5
9
4
-1 2 3 -4
1
Sub-sequence found.

Sub-sequence found.

</p>