题目链接:https://codeforc.es/contest/1186/problem/C

题目大意:xxxxx(自认为讲不清。for instance)

  例如:a="01100010" b="00110"。

  我们把a截到b的长度就有4个字串。

  a1=01100 a2=11000 a3=10001 a4=00010

  f(s1,s2)表示是s1与s2异或后1的个数

  题目要求每个a子串与b的f(ai,b)的值为偶数的个数。

ps:暑假第一天,签到写个稍微简单一点的题

思路:

  如果在例子中b串是"00000"。那么题目变为求ai的1的个数为偶数的个数

  这里我们用前缀和来求就非常好了。

  a1= 01100 符合题意

  a2= 11000 符合题意

  a3= 10001 符合题意

  a4= 00010 不符合题意

  前缀和应该会吧。O(1)就可以知道和。然后判断一下奇偶就好了

  

  但是b串不一定是"00000"

  这时我们看一下如果b="00100"会怎么样?

  a1= 01000 不符合题意

  a2= 11100 不符合题意

  a3= 10101 不符合题意

  a4= 00110 符合题意

  所以,我们可以得出当b串的1的个数为奇数是我们求a子串的1的个数为奇数的个数

  反之,求偶数的个数

  愉快的贴代码^-^

  

#include <bits/stdc++.h>
using namespace std;
#define N 1000100 int x[N];
int ser=;
signed main()
{
ios::sync_with_stdio(false);
string s,ss;
cin>>s>>ss; for(auto&c:s){
int a=(c=='');
x[++ser]=a;
x[ser]+=x[ser-];
} int b=;
for(auto&c:ss){
b^=(c=='');
}
int Ans=;
for(int i=ss.size();i<=ser;i++){
//cout<<x[i]<<" "<<x[i-ss.size()]<<endl;
Ans+=!((x[i]-x[i-ss.size()])&)^b;
}
cout<<Ans;
return ;
}

  

codeforces 1186C 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 - 1186 C. Vus the Cossack and Strings (异或)

    Vus the Cossack has two binary strings, that is, strings that consist only of "0" and &quo ...

  3. 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 ...

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

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

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

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

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

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

  7. 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 ...

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

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

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

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

随机推荐

  1. Codeforces Global Round 4 Prime Graph CodeForces - 1178D (构造,结论)

    Every person likes prime numbers. Alice is a person, thus she also shares the love for them. Bob wan ...

  2. Lindström–Gessel–Viennot lemma

    解决不相交路径计数 有两个大小为N的点集A,B A上每一个点对应着B的每一个点 求满足条件的路径集合有多少个 图里面可能还有一些障碍 Codeforces 348 D 有一个N*M的网格图 有两个点 ...

  3. qt常用技巧

    发布程序:windeployqt hello.exe QString乱码问题,在字符串前加u8

  4. centos安装mysql的正确方法

    1.官方安装文档 http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/ 2.下载 Mysql yum包 http://dev.mysql.co ...

  5. inoutfy与rsync进行实时同步

    更新阿里epel源 安装镜像源 curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo --- 扩展 ...

  6. WPF 多个选项卡TabControl 页面分离

    此项目源码下载地址:https://github.com/lizhiqiang0204/TabControl-page-separation 每个页面的按键处理事件直接对应该页面下的cs文件 Main ...

  7. 从输入一个URL到页面渲染的流程简介

    首先说明以下是我参考网上答案和自己的思考,给出自己的想法,如果有问题,欢迎大家吐槽从用户在浏览器中输入一个URL,到整个页面渲染,这个过程中究竟发生了什么呢?今天先简单写下整个过程,后面再一点点完善. ...

  8. 开发第一个VUE插件

    背景 项目中用到element-ui,里面用到了弹出组件,但是效果不太满意,于是自己就想写一个简单的弹出组件.目前已经发布到npm:可以通过npm i dialog-wxy -s 进行下载使用页面调用 ...

  9. NETCONF

    NETCONF协议(Network Configration Protocol) NETCONF是一个基于XML的交换机配置接口,用于替代CLI.SNMP等配置交换机. 本质上来说,NETCONF就是 ...

  10. wordpress在线预览pdf插件

    插件名称:PDF.js Viewer Shortcode 插件主页:http://tphsfalconer.com/ 优点:功能强大,有分页缩略图功能,翻页,放大缩小,打印,下载,读取等功能. 使用方 ...