Advertisement
STANAANDREY

Vus the Cossack and Strings

Sep 19th, 2019
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define uns unsigned
  3. #define ll long long
  4. const char newline('\n');
  5. using namespace std;
  6. ///**************************contest setup
  7.  
  8. string a, b;
  9. unsigned res;
  10.  
  11. int main()
  12. {
  13.     getline(cin, a);
  14.     getline(cin, b);
  15.     const int sa = a.size(), sb = b.size();
  16.     vector <int> spa(sa + 5, 0);
  17.  
  18.     for (int i = 1; i <= sa; i++)
  19.     {
  20.         spa.at(i) = spa.at(i - 1) + int(a.at(i - 1) - '0');
  21.     }
  22.  
  23.     const int nrof1 = count(b.begin(), b.end(), '1');
  24.     for (int i = sb; i <= sa ; i++)
  25.     {
  26.         if (((spa.at(i) - spa.at(i - sb)) % 2) == (nrof1 % 2))
  27.             res++;
  28.     }
  29.  
  30.     cout << res;//*/
  31.  
  32.     return EXIT_SUCCESS;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement