Vus the Cossack has two binary strings, that is, strings that consist only of "0" and "1". We call these strings aa and bb. It is known that |b|≤|a||b|≤|a|, that is, the length of bb is at most the length of aa.

The Cossack considers every substring of length |b||b| in string aa. Let's call this substring cc. He matches the corresponding characters in bband cc, after which he counts the number of positions where the two strings are different. We call this function f(b,c)f(b,c).

For example, let b=00110b=00110, and c=11000c=11000. In these strings, the first, second, third and fourth positions are different.

Vus the Cossack counts the number of such substrings cc such that f(b,c)f(b,c) is even.

For example, let a=01100010a=01100010 and b=00110b=00110. aa has four substrings of the length |b||b|: 0110001100, 1100011000, 1000110001, 0001000010.

  • f(00110,01100)=2f(00110,01100)=2;
  • f(00110,11000)=4f(00110,11000)=4;
  • f(00110,10001)=4f(00110,10001)=4;
  • f(00110,00010)=1f(00110,00010)=1.

Since in three substrings, f(b,c)f(b,c) is even, the answer is 33.

Vus can not find the answer for big strings. That is why he is asking you to help him.

Input

The first line contains a binary string aa (1≤|a|≤1061≤|a|≤106) — the first string.

The second line contains a binary string bb (1≤|b|≤|a|1≤|b|≤|a|) — the second string.

Output

Print one number — the answer.

Examples
input

Copy
01100010
00110
output

Copy
3
input

Copy
1010111110
0110
output

Copy
4
 题意:
给出一个01字符串a,一个01字符串b,将a中每一个长度和b相等的子串取出,问有多少个子串,和b对应位置上数字不同的个数是偶数。
 
思路:
使用异或运算即可。
充分利用异或可交换的性质。
 
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime> #define fuck(x) cout<<#x<<" = "<<x<<endl;
#define debug(a, x) cout<<#a<<"["<<x<<"] = "<<a[x]<<endl;
#define ls (t<<1)
#define rs ((t<<1)|1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = ;
const int maxm = ;
const int inf = 0x3f3f3f3f;
const ll Inf = ;
const int mod = ;
const double eps = 1e-;
const double pi = acos(-); char a[maxn],b[maxn]; int main() {
// ios::sync_with_stdio(false);
// freopen("in.txt", "r", stdin); scanf("%s%s",a,b);
int lena = strlen(a);
int lenb = strlen(b); int ans=;
for(int i=;i<lenb;i++){
ans^=(a[i]-)^(b[i]-);
} int sum=;
if(!ans){sum++;} for(int i=lenb;i<lena;i++){
ans^=(a[i]-)^(a[i-lenb]-);
if(!ans){sum++;}
}
printf("%d",sum); return ;
}
 

CodeForces - 1186 C. Vus the Cossack and Strings (异或)的更多相关文章

  1. Vus the Cossack and Strings(Codeforces Round #571 (Div. 2))(大佬的位运算实在是太强了!)

    C. Vus the Cossack and Strings Vus the Cossack has two binary strings, that is, strings that consist ...

  2. codeforces 1186C Vus the Cossack and Strings

    题目链接:https://codeforc.es/contest/1186/problem/C 题目大意:xxxxx(自认为讲不清.for instance) 例如:a="01100010& ...

  3. C Vus the Cossack and Strings ( 异或 思维)

    题意 : 给你两个只包含 0 和 1 的字符串 a, b,定义函数 f ( A, B ) 为 字符串A和字符串B 比较 存在多少个位置 i 使得 A[ i ] != B[ i ] ,例如 f(0011 ...

  4. 『Codeforces 1186E 』Vus the Cossack and a Field (性质+大力讨论)

    Description 给出一个$n\times m$的$01$矩阵$A$. 记矩阵$X$每一个元素取反以后的矩阵为$X'$,(每一个cell 都01倒置) 定义对$n \times m$的矩阵$A$ ...

  5. Codeforces F. Vus the Cossack and Numbers(贪心)

    题目描述: D. Vus the Cossack and Numbers Vus the Cossack has nn real numbers aiai. It is known that the ...

  6. Codeforces Round #571 (Div. 2)-D. Vus the Cossack and Numbers

    Vus the Cossack has nn real numbers aiai. It is known that the sum of all numbers is equal to 00. He ...

  7. E. Vus the Cossack and a Field (求一有规律矩形区域值) (有一结论待证)

    E. Vus the Cossack and a Field (求一有规律矩形区域值) 题意:给出一个原01矩阵,它按照以下规则拓展:向右和下拓展一个相同大小的 0 1 分别和原矩阵对应位置相反的矩阵 ...

  8. Codeforces 1186F - Vus the Cossack and a Graph 模拟乱搞/欧拉回路

    题意:给你一张无向图,要求对这张图进行删边操作,要求删边之后的图的总边数 >= ceil((n + m) / 2), 每个点的度数 >= ceil(deg[i] / 2).(deg[i]是 ...

  9. @codeforces - 1186F@ Vus the Cossack and a Graph

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个 n 点 m 边的图(n, m<=10^6),记第 ...

随机推荐

  1. JavaScript--函数中()的作用

    在函数中参数是函数的时候:function a(函数名) 与 function a(函数名()) 的区别: // 在函数里面() 是一个编组和立即执行的功能 /** * function autoPl ...

  2. C++ 标准库 permutation

    首先,permutation指的是对元素的重排,比方a , b , c 三个元素的全部的重排为    abc, acb, bac,bca,cab,cba 总共 3!  = 6 中情况,可是怎样声称这六 ...

  3. java返回结果集封装

    1.返回消息统一定义文件CodeMsg.java public class CodeMsg { private int retCode; private String message; // 按照模块 ...

  4. CNN对位移、尺度和旋转不变性的讨论

    CNN得益于全局共享权值和pool操作,具有平移不变性. 对于尺度不变性,是没有或者说具有一定的不变性(尺度变化不大),实验中小目标的检测是难点,需要采用FPN或者其他的方式单独处理. 对于旋转不变性 ...

  5. HDU_2035:人见人爱A^B

    Problem Description 求A^B的最后三位数表示的整数. 说明:A^B的含义是“A的B次方”   Input 输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1< ...

  6. UVA_401:Palindromes

    AC:Time(29ms)     C++ 4.8.2 #include<stdio.h> #include<string.h> char * mirstr = "A ...

  7. vuex之仓库数据的设置与获取

    如果你之前使用过vue.js,你一定知道在vue中各个组件之间传值的痛苦,在vue中我们可以使用vuex来保存我们需要管理的状态值,值一旦被修改,所有引用该值的地方就会自动更新,那么接下来我们就来学习 ...

  8. JPA使用nativequery多表关联查询返回自定义实体类

    本文为JPA的学习采坑,如有问题欢迎指正. JPA官方推荐的多表关联查询使用不便,接触的有些项目可能会使用JPA 做简单查询,Mybaits做复杂查询.所以想要寻找一种好用的解决方案. JPA多表关联 ...

  9. python for 循环结构

  10. javascript简介 标签: javascript 2015-11-13 12:13 1712人阅读 评论(39)

    JavaScript是一种属于网络的脚本语言,已经被广泛用于Web应用开发,常用来为网页添加各式各样的动态功能,为用户提供更流畅美观的浏览效果.通常JavaScript脚本是通过嵌入在HTML中来实现 ...