#include <cstring>#include <cstdio>using namespace std;typedef long long LL;const int maxn = 3 * 1E5 + 10;char str[maxn];int main(){scanf("%s",str);int n = strlen(str);LL ans = 0;int tmp;for(int i = 0 ; i < n; ++i){int tmp = str[i] - ‘0‘;if(tmp % 4 == 0) ++ans;if(i){tmp = (str[i-1] - ‘0‘)*10 + tmp;if(tmp % 4 == 0) ans += i;}}printf("%I64d\n",ans);return 0;}
[2016-04-08][codeforces][628][B][New Skateboard]
原文:http://www.cnblogs.com/qhy285571052/p/d23ff9110359c6c71e722fb3638ebb22.html