Stephan Says Six Seven
Problem Statement
Unfortunately, after doomscrolling Instagram for 6 to 7 hours each day, Stephan has become obsessed with the corny '6 7' meme, and likes to say '6 7' really loudly for no reason.
One day, Stephan says a sequence with numbers (), each of which is either 6 or 7. It is guaranteed that has at least one 6 and one 7. (After all, to get the full effect of a '6 7', you have to say both numbers!)
Define a six-seven to be a pair of two indices such that if one were to remove every single other index from the list other than those two, the number at the first index would be 6, and the number at the second index would be 7.
Solve for the number of six-sevens in the sequence that Stephan says. (Whew, that's a tongue twister!)
Input Format
The first line contains .
The second line contains the sequence, .
Output Format
One line with the answer.
Note that the answer for this problem could be really large; thus, for C++ and Java users, it is best if your answer is in the form of a 64-bit integer (e.g. a "long long") instead of the normal 32-bit integer.
Constraints
- •
- • contains only the digits 6 and 7
- • has at least one 6 and one 7
Sample Test Cases
Sample Input 1
7 6666667
Sample Output 1
6
Explanation: The possible six-sevens are at indices (i, j) = (0, 6), (1, 6), (2, 6), (3, 6), (4, 6), and (5, 6).
Sample Input 2
6 667767
Sample Output 2
7
Sample Input 3
4 7766
Sample Output 3
0
Test Case Information
- • For test cases 4–6, .
- • For test cases 7–10, .
- • For test cases 11–20, .
- • For test cases 4, 7, and 11, it is guaranteed that there is exactly one 7 in .
Submit Solution (Practice)
Submission History
| ID | Language | Verdict | Score | Submitted (PST) | |
|---|---|---|---|---|---|
| No submissions yet. | |||||