CF1139A.Even Substrings

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a string s=s1s2sns=s_1s_2\dots s_n of length nn , which only contains digits 11 , 22 , ..., 99 .

A substring s[lr]s[l \dots r] of ss is a string slsl+1sl+2srs_l s_{l + 1} s_{l + 2} \ldots s_r . A substring s[lr]s[l \dots r] of ss is called even if the number represented by it is even.

Find the number of even substrings of ss . Note, that even if some substrings are equal as strings, but have different ll and rr , they are counted as different substrings.

输入格式

The first line contains an integer nn ( 1n650001 \le n \le 65000 ) — the length of the string ss .

The second line contains a string ss of length nn . The string ss consists only of digits 11 , 22 , ..., 99 .

输出格式

Print the number of even substrings of ss .

输入输出样例

  • 输入#1

    4
    1234
    

    输出#1

    6
  • 输入#2

    4
    2244
    

    输出#2

    10

说明/提示

In the first example, the [l,r][l, r] pairs corresponding to even substrings are:

  • s[12]s[1 \dots 2]
  • s[22]s[2 \dots 2]
  • s[14]s[1 \dots 4]
  • s[24]s[2 \dots 4]
  • s[34]s[3 \dots 4]
  • s[44]s[4 \dots 4]

In the second example, all 1010 substrings of ss are even substrings. Note, that while substrings s[11]s[1 \dots 1] and s[22]s[2 \dots 2] both define the substring "2", they are still counted as different substrings.

首页