这个题吧

你画一下就知道了

就拿这个例子来讲

4 5
1001
10101

对于b串的话第5位只会经过a串的第4位,b串的第4位会经过a串的第3位和第4位。。。。。b串的第1和第2位会经过a串的每一位

由于是&操作,计算1经过a串每一位所能带来的权值,

对b串进行处理,相加即可

#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define x first
#define y second
using namespace std;
const int maxn = 2e5+;
const ll mod = ;
ll fac[maxn];
ll rea[maxn];
ll ans1,ans2;
char a[maxn];
char b[maxn];
int main()
{
//freopen("in.txt","r",stdin);
ll n,m;
scanf("%lld%lld",&n,&m);
scanf("%s %s",a,b);
fac[] = ;
for(int i = ; i < n; ++i){
fac[i] = *fac[i-]%mod;
} for(int i = ; i < n/; ++i)
{
swap(a[i],a[n--i]);
}
for(int i = ; i < m/; ++i)
{
swap(b[i],b[m--i]);
} rea[] = ;
if(a[] == '')
rea[] = ;
for(int i = ; i < n; ++i)
{
rea[i] = rea[i-];
if(a[i] == '')
rea[i] = (rea[i]+fac[i]);
} for(int i = ; i < n; ++i)
{
if(a[] == '')
ans1 = (ans1 + rea[i])%mod;
} ll ans = ;
for(int i = ; i < n && i < m; ++i)
{
if(b[i] == '')
{
ans = (ans+rea[i])%mod;
}
} for(int i = n; i < m; ++i)
{
if(b[i] == '')
ans = (ans+rea[n-])%mod;
} cout << ans << endl;
}

codefores 1066 E. Binary Numbers AND Sum的更多相关文章

  1. Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum

    E. Binary Numbers AND Sum 题目链接:https://codeforces.com/contest/1066/problem/E 题意: 给出两个用二进制表示的数,然后将第二个 ...

  2. Binary Numbers AND Sum CodeForces - 1066E (前缀和)

    You are given two huge binary integer numbers aa and bb of lengths nn and mmrespectively. You will r ...

  3. E. Binary Numbers AND Sum

    链接 [http://codeforces.com/contest/1066/problem/E] 题意 给你长度分别为n,m的二进制串,当b>0时,对a,b,&运算,然后b右移一位,把 ...

  4. CF1066E Binary Numbers AND Sum

    思路: 模拟.实现: #include <iostream> using namespace std; ; ], b[]; ]; int main() { int n, m; while ...

  5. Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum (二进制,前缀和)

    题意:有两个\(01\)字符串\(a\)和\(b\),每次让\(a\)和\(b\)进行与运算,将值贡献给答案,然后将\(b\)右移一位,直到\(b=0\). 题解:因为\(a\)不变,而\(b\)每次 ...

  6. 【Leetcode_easy】1022. Sum of Root To Leaf Binary Numbers

    problem 1022. Sum of Root To Leaf Binary Numbers 参考 1. Leetcode_easy_1022. Sum of Root To Leaf Binar ...

  7. LeetCode 1022. 从根到叶的二进制数之和(Sum of Root To Leaf Binary Numbers)

    1022. 从根到叶的二进制数之和 1022. Sum of Root To Leaf Binary Numbers 题目描述 Given a binary tree, each node has v ...

  8. HDU-1390 Binary Numbers

    http://acm.hdu.edu.cn/showproblem.php?pid=1390 Binary Numbers Time Limit: 2000/1000 MS (Java/Others) ...

  9. [LeetCode#110, 112, 113]Balanced Binary Tree, Path Sum, Path Sum II

    Problem 1 [Balanced Binary Tree] Given a binary tree, determine if it is height-balanced. For this p ...

随机推荐

  1. ASCII,Unicode,GBK和UTF-8字符编码的区别和联系

    如果经常写python2,肯定会遇到各种“奇怪”的字符编码问题,每次都通过谷歌解决了,但是为什么会造成这种乱码.decode/encode失败等等,本文就字符和字符编码做一个总结,更加清晰区分诸多的编 ...

  2. Linux - 系统信息相关命令

    系统信息相关命令 本节内容主要是为了方便通过远程终端维护服务器时,查看服务器上当前 系统日期和时间 / 磁盘空间占用情况 / 程序执行情况 本小结学习的终端命令基本都是查询命令,通过这些命令对系统资源 ...

  3. js 一键复制

    function copyURL(id){ var siteId=$("#siteId").val() var oInput = document.createElement('i ...

  4. 初学c# -- 记录QQ键盘

    扫描进程,如果QQ启动了,开始记录键盘,别的程序都不记录.记录到e:\log.txt里面,当然也可以修改为截屏+记录发送到邮箱或客户端 进程 Process[] p = Process.GetProc ...

  5. 国内安装helm

    helm repo remove stable helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts ...

  6. CentOS 6安装配置mongodb

    安装过程 服务器下载安装包 下载: curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-4.0.6.tgz; 解压 ...

  7. server 打开失败

    server:An unexpected exception was thrown. 当server服务器遇到这样遇到不能料想的错误导致打开失败的情况下,我们可以找到一个com.genuitec.ec ...

  8. Python并发解决方案

    一.subprocess模块 call():执行命令,返回程序返回码(int) import subprocess print(subprocess.call("mspaint") ...

  9. vs2013 v8编译

    最新v8,只能在vs2015编译(在官网看了资料,新版本v8/chrome使用的c++11特性只能用vs2015编译) vs2015 vc需要的dll有近50个,发布不太方便,所以采用vs2013up ...

  10. css -html-文档流

    首先先考虑一下什么是普通流?普通流就是正常的文档流,在HTML里面的写法就是从上到下,从左到右的排版布局. 例: <div id="01"></div>&l ...