#OLD46. Even Substrings
Even Substrings
Description
You are given a string s=s1s2…sn of length n, which only contains digits 1, 2, ..., 9.
A substring s[l…r] of s is a string sl ,sl+1, sl+2…sr. A substring s[l…r] of s is called even if the number represented by it is even.
Find the number of even substrings of s. Note, that even if some substrings are equal as strings, but have different l and r, they are counted as different substrings.
Format
Input
The first line contains an integer n (1≤n≤65000) — the length of the string s.
The second line contains a string s of length n. The string s consists only of digits 1, 2, ..., 9.
Output
Print the number of even substrings of s.
Samples
4
1234
6
4
2244
10
Hint
In the first example, the[l,r][l,r]pairs corresponding to even substrings are:
- s[1…2]s[1…2]
- s[2…2]s[2…2]
- s[1…4]s[1…4]
- s[2…4]s[2…4]
- s[3…4]s[3…4]
- s[4…4]s[4…4]
In the second example, all1010substrings ofssare even substrings. Note, that while substringss[1…1]s[1…1]ands[2…2]s[2…2]both define the substring "2", they are still counted as different substrings.