这个题吧

你画一下就知道了

就拿这个例子来讲

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. Python库 - Albumentations 图片数据增强库

    Python图像处理库 - Albumentations,可用于深度学习中网络训练时的图片数据增强. Albumentations 图像数据增强库特点: 基于高度优化的 OpenCV 库实现图像快速数 ...

  2. Exp2 后门原理与实践 20165110

    Exp2 后门原理与实践 一.实验要求 1.使用netcat获取主机操作Shell,cron启动 2.使用socat获取主机操作Shell, 任务计划启动 3.使用MSF meterpreter(或其 ...

  3. UnitZ Battlegrounds beta5 - Unity吃鸡类型游戏模版 源码 仿绝地求生

    Requires Unity 2018.2.6 or higher.The first battle royale game starter kit on Asset Store, all syste ...

  4. 关于sqlserver使用in不报错问题

    最近使用CI处理接口时自己拼装了个函数,直接把数字implode(',',$arr)之后就放在了in中,发现一直返回空数据,以为数据库就是无匹配的,但是后面发现有对应的数据,多搬检测没发现问题,后面发 ...

  5. 理解javascript中的立即执行函数(function(){})()

    之前看了好多代码,都有用到这种函数的写法,但是都没认真的去想为什么会这样写,今天开始想学习下jquery的源码,发现jquery也是使用这种方式,用(function(window, undefine ...

  6. ios UITableView的style的区别与用法,以及分割线的显示与隐藏

    ******************tableview style****************************************************** // tableview ...

  7. git安装包解压后没有configure

    今天在linux上安装git客户端,解压了tar包后,发现没有configure,无法安装.经查,原来是要先执行autoconf命令,执行后出现configure

  8. oracle错误(ORA:12154 ORA:01034 和 ORA:27101 ORA-18008 ORA-01081)

    按照正常操作流程,启动项目,发现项目报错,原因是连接不上oracle数据库, PLSQL连接时报错,错误码  ORA:12154 无法解析指定的连接标识符 第一次,遇到这个错误,在网上找了资料都是需要 ...

  9. $.isPlainObject

    // Support: IE<9 // Handle iteration over inherited properties before own properties. if ( !suppo ...

  10. Sublime Text Snippets(代码片段)功能

    原文链接:http://www.bluesdream.com/blog/sublime-text-snippets-function.html 我们在编写代码的时候,总会遇到一些需要反复使用的代码片段 ...