New Skateboard
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Meanwhile his little brother Yusuf came and started to press the keys randomly. Unfortunately Max has forgotten the number which he had calculated. The only thing he knows is that the number is divisible by 4.

You are given a string s consisting of digits (the number on the display of the calculator after Yusuf randomly pressed the keys). Your task is to find the number of substrings which are divisible by 4. A substring can start with a zero.

A substring of a string is a nonempty sequence of consecutive characters.

For example if string s is 124 then we have four substrings that are divisible by 4: 12, 4, 24 and 124. For the string 04 the answer is three: 0, 4, 04.

As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to usegets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead ofScanner/System.out in Java.

Input

The only line contains string s (1 ≤ |s| ≤ 3·105). The string s contains only digits from 0 to 9.

Output

Print integer a — the number of substrings of the string s that are divisible by 4.

Note that the answer can be huge, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

Examples
input
124
output
4
input
04
output
3
input
5810438174
output

9

题目大意:给一个字符串,判断子串中有几个能被4整除

题解:能被4整除的数满足最后两位能被4整除,寻找出所有子串判断即可

#include <stdio.h>
#include <string.h>
];
__int64 sum=;
int main()
{
    int i;
    gets(s);
    ;i>;i--)
    {
        ]-)%==)
            sum += i;
    }
    ;i<strlen(s);i++)
        ==)
            sum++;
    printf("%I64d\n", sum);
    ;
}

CodeForces 628B New Skateboard的更多相关文章

  1. CodeForces 628B New Skateboard 思维

    B. New Skateboard time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  2. CF 628B New Skateboard --- 水题

    CD 628B 题目大意:给定一个数字(<=3*10^5),判断其能被4整除的连续子串有多少个 解题思路:注意一个整除4的性质: 若bc能被4整除,则a1a2a3a4...anbc也一定能被4整 ...

  3. codeforces 628B B. New Skateboard (数论)

    B. New Skateboard time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  4. Codefroces 628B New Skateboard(数位+思维)

    题目链接:http://codeforces.com/contest/628/problem/B 题目大意:给你一段数字串s(1?≤?|s|?≤?3·10^5),求该字符串有多少子串是4的倍数.解题思 ...

  5. Codeforces 682B New Skateboard(DP)

    题目大概说给一个数字组成的字符串问有几个子串其代表的数字(可以有前导0)能被4整除. dp[i][m]表示字符串0...i中mod 4为m的后缀的个数 通过在i-1添加str[i]字符转移,或者以st ...

  6. Educational Codeforces Round 8

    开始填坑_(:з」∠)_ 628A - Tennis Tournament    20171124 小学数学题,\((x,y)=((n-1)\cdot(2b+1),np)\) #include< ...

  7. SZU3

    CodeForces 343A 这是第一题,像这种水题一定不要想复杂,思路不对立马换. 抓住串联和并联,可以用辗转相除法 #include <iostream> #include < ...

  8. Educational Codeforces Round 8 B. New Skateboard 暴力

    B. New Skateboard 题目连接: http://www.codeforces.com/contest/628/problem/A Description Max wants to buy ...

  9. Codeforces CF#628 Education 8 B. New Skateboard

    B. New Skateboard time limit per test 1 second memory limit per test 256 megabytes input standard in ...

随机推荐

  1. spark-submit常用参数

    yarn模式默认启动2个executor,无论你有多少的worker节点 standalone模式每个worker一个executor,无法修改executor的数量 partition是RDD中的一 ...

  2. C# 把字符串类型日期转换为日期类型

    方法一:Convert.ToDateTime(string) string格式有要求,必须是yyyy-MM-dd hh:mm:ss ================================== ...

  3. 省市区三级联动(二)JS部分简单版

    通过对上一篇<省市区三级联动>的学习发现JScript部分省市区的填充代码几乎相同,所以可以写成一个函数. 注意:html部分和chuli.php部分不变 1.下拉列表填充可以写成带参数的 ...

  4. where 子句和having子句中的区别

    1.where 不能放在GROUP BY 后面 2.HAVING 是跟GROUP BY 连在一起用的,放在GROUP BY 后面,此时的作用相当于WHERE 3.WHERE 后面的条件中不能有聚集函数 ...

  5. 电脑配置 eclipse 环境变量

    先找到电脑环境变量 我的电脑——属性——高级系统设置——环境变量 path里面需要两个环境 第一个Java 环境 C:\Program Files\Java\jdk1.8.0_40\bin; 第二个a ...

  6. D5转Xe点滴

    1. VarIsNull 函数已经被 Variants 单元, 相应的 Var 相关都放在哪 2.原本在 SysUtils 下的部分格式函数或定义,例如 .DecimalSeparator:  Sho ...

  7. Spring使用p名称空间配置属性

    给XML配置文件"减肥"的另一个选择就是使用p名称空间,从 2.0开始,Spring支持使用名称空间的可扩展配置格式.这些名称空间都是基于一种XML Schema定义.事实上,我们 ...

  8. 【Pro ASP.NET MVC 3 Framework】.学习笔记.2.MVC的主要工具-Ninject

    这三个工具,应该是每个MVC程序员的兵工厂中的一部分.DI容器,单元测试框架,mocking 工具.Ninject是我们偏爱的DI容器,它简单,高雅,并且容易使用.这里有很多复杂的替代品,但是我们喜欢 ...

  9. 25、oracle(一)

    1)了解oracle背景,概念和特点 2)掌握oracleSQL对单表各种查询操作 3)掌握oracleSQL中函数的使用 4)掌握数值型number,字符串型varchar2,日期型date,条件判 ...

  10. 处理字符串中的换行,将textarea中的带有换行的字符串变为逗号分隔的写法

    _setMultipleInputValues: function (param) { //Maybe need to modify here for the new parameter //add ...