CF1139A.Even Substrings
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 slsl+1sl+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.
输入格式
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 .
输出格式
Print the number of even substrings of s .
输入输出样例
输入#1
4 1234
输出#1
6
输入#2
4 2244
输出#2
10
说明/提示
In the first example, the [l,r] pairs corresponding to even substrings are:
- s[1…2]
- s[2…2]
- s[1…4]
- s[2…4]
- s[3…4]
- s[4…4]
In the second example, all 10 substrings of s are even substrings. Note, that while substrings s[1…1] and s[2…2] both define the substring "2", they are still counted as different substrings.