Problem W
Counting Subsequences (Hard)
“
For example, the first ten digits of the Euler’s constant are:
2 7 1 8 2 8 1 8 2 8
And what’s their sum? Of course, it is
Try walking around with your eyes open. You may be sure that
soon you will start discovering occurrences of the number
You are given a sequence
E.g., consider the sequence
Given a sequence
Input
The first line of the input file contains an integer
The first line of each test case contains the length of a
sequence
Output
For each test case output a single line containing a single integer – the count of interesting subsequences of the given sentence.
Sample Input 1 | Sample Output 1 |
---|---|
2 13 -2 7 1 8 2 8 -1 8 2 8 4 -5 -9 7 2 47 10047 47 1047 47 47 |
1 4 |