地址:http://codeforces.com/contest/1186/problem/C
思路:enn...想不到,还是思维太常规了,
借鉴博客:https://www.cnblogs.com/DreamACMer/p/11107034.html
由于只需要求01不同个数的奇偶数,因此可以用异或来求解
Code:
#include<iostream>
using namespace std;
int n,m;
string a,b;
int main()
{
ios::sync_with_stdio(false);
cin>>a>>b;
n=a.length();
m=b.length();
int res=n-m+1,s=0;
for(int i=0;i<m;++i)
s^=(a[i]-'0')^(b[i]-'0');
res-=s;
for(int i=m;i<n;++i)
{
s^=(a[i-m]-'0')^(a[i]-'0');
res-=s;
}
cout<<res<<endl;
return 0;
}