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. paper 60 :转载关于视觉SCI期刊

    ChanLee_1整理的计算机视觉领域稍微容易中的期刊 模式识别,计算机视觉领域,期刊 (1)pattern recognition letters, 从投稿到发表,一年半时间 (2)Pattern  ...

  2. paper 40 :鲁棒性robust

    最近只想安心.安静的科研,不想被任何人打扰,继续做自己,不忘初心,方得始终! 首先了解下鲁棒性这个词的定义.鲁棒性是指控制系统在一定(结构,大小)的参数摄动下,维持某些性能的特性.根据对性能的不同定义 ...

  3. YbRapidSolution.MVC项目首页分页没有起作用

    @model YbRapidSolution.Mvc.Models.CmsPagerDataModel <nav> <ul class="pager"> & ...

  4. -XX:+PrintHeapAtGC 每次一次GC后,都打印堆信息

    -XX:+PrintHeapAtGC每次一次GC后,都打印堆信息 {Heap before GC invocations=0 (full 0): def new generation   total ...

  5. 夺命雷公狗ThinkPHP项目之----企业网站24之网站前台获取当前栏目和顶级栏目

    我们现在要实现的是取出网站当前栏目名称和顶级分类名称,如下所示: 列表页的和单页的不能总是写死的吧?? 我能就要想办法去让他变活的才可以解决问题噢,我们已经有了他的cate_id ,然后我们就可以通过 ...

  6. Scrum站立会议----11月4日

    小组名称:nice! 组长:李权 成员:于淼  刘芳芳韩媛媛 宫丽君 时间:2016.11.4    12:00--12:30 地点:传媒西楼220室 代码地址:Https:  https://git ...

  7. empty()、html("")和text("")

    empty().html("")和text("")在删除匹配元素内内容时是一样的.jQuery源码中实现有所不同,但效果相同.可以测试一下源码: <!DO ...

  8. MYSQL 、Oracle、SQLServer 数据库中时间的格式化输出

    在MYSQL 中格式化输出 date_forma t(date,'yyyyMMddHHmmss') Oracle 中格式化输出 to_char(time ,'yyyyMMddHHmmss') SQL ...

  9. 不允许调用库函数,也不允许使用任何全局或局部变量编写strlen函数

    不允许调用库函数,也不允许使用任何全局或局部变量编写strlen函数. 这是一道面试题,可以使用递归的方式解答,答案如下: #include <stdio.h> int mylen(cha ...

  10. java中枚举类的使用详解

    /* * 通过JDK5提供的枚举来做枚举类 */ public enum Direction2 { FRONT("前"), BEHIND("后"), LEFT( ...