B. 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 use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/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
个位十位分情况讨论
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
char a[];
int main()
{
scanf("%s",&a);
ll ans=;
int len=strlen(a);
int k=(int)a[]-;
if(k%==) ans++;
for(int i=;i<len;i++)
{
k=(int)a[i]-;
if(k%==) ans++;
int s=(int)a[i-]-;
if((s*+k)%==) ans+=i;
}
printf("%I64d\n",ans);
return ;
}

最新文章

  1. Spring获取ApplicationContext
  2. JQuery之$.ajaxPOST数据
  3. Intellij Idea 工具在java文件中如何避免 import .*包
  4. 他们在军训,我在搞 OI(Ending)
  5. 关于mac下面用Parallels装ubuntu时分辨率问题[已解决]
  6. 新版ADT出现appcompat_v7的问题
  7. 使用maven编译的时候提示 maven-source 1.3 中不支持注释请使用 -source 5 或更高版本以启用注释的错误。
  8. ImCash:第一个集多功能于一身的数字资产平台
  9. Dota 2 中安装包的作用
  10. 【python010-数组】
  11. Microsoft Windows远程桌面协议中间人攻击漏洞(CVE-2005-1794)漏洞解决方案(Windows server2003)
  12. 【Jmeter自学】Jmeter脚本录制(二)
  13. oracle exp/imp命令详解
  14. 【转】UIAutomator源码分析之启动和运行
  15. 关于Java中语句符号及格式的理解
  16. Mongodb3.X版本的 的用户认证
  17. JAVA—IO操作
  18. 关于Javascript表单验证
  19. 【LeetCode】78. Subsets (2 solutions)
  20. 加密shell

热门文章

  1. 栈 &lt;stack&gt; F - 宋飞正传
  2. apache(XAMPP)禁止IP访问的httpd-vhosts.conf设置
  3. Vue和vue-template-compiler版本之间的问题
  4. STM32中断名词
  5. Spring学习总结(13)——Spring+Log4j+ActiveMQ实现远程记录日志
  6. HTML学习----------DAY2第五节
  7. HDOJ 2544 最短路(最短路径 dijkstra算法,SPFA邻接表实现,floyd算法)
  8. 《机器学习系统设计》之应用scikit-learn做文本分类(上)
  9. BZOJ 1103 DFS序+线段树
  10. POJ 1293 网络流 第一题