- Time: 2016-04-08-13:24:57
- Title Number: [2016-04-08][codeforces][628][b][new skateboard]
- The main topic: given a length of the most 3x5 3 x 5 String, asking how many substrings can be divisible by 4,
- Analysis:
- Two digits after each number can be divisible by 4, then this number will be divisible by 4.
- Dp[i] Indicates the number of words RP divisible by 4 from 0~i, then dp[i] = dp[i-1] + (a[i]%4 = 0) + ((a[i-1] * + a[i])%4?0:i)
- That is, if the potential of the first can be divisible by 4, then the answer is +1, if the second bit is added, the next two bits are divisible by 4, then the answer is to add I, because the string containing the next two bits have I
#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 = Span class= "PLN" > ( str [ i - 1 - ' 0 ' 10 + tmp
if(tmp % 4 == 0) ans += i;
}
}
printf("%I64d\n",ans);
return 0;
}
From for notes (Wiz)
[2016-04-08] [Codeforces] [628] B [New Skateboard]