这个题吧

你画一下就知道了

就拿这个例子来讲

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. 使用Fiddle抓取IOS手机

    1.配置Fiddle (Tools->Options) 勾选后,按照提示下载安装一个认证 Fiddle默认8888端口 2.电脑开个热点,手机连上后,在该wifi的代理配置中,选择手动,服务器输 ...

  2. Python设计模式 - UML - 状态图(State Machine Diagram)

    简介 状态图主要用于描述对象在其生命周期中各种状态.状态之间的转换过程.触发状态转换的各种事件(条件)及执行的动作. 状态图构建步骤 - 找出适合用状态图描述的类.确定类中需要做状态图的重要对象 - ...

  3. NET CORE 2.0发布在IIS上提示502.5错误

    在装了WindowsHosting和NET CORE SDK后,如果没有重启服务器,访问站点报以上错误,解决办法要么重启,要么执行以下两条命令: net stop was /y net start w ...

  4. CentOS7 常用设置

    安装配置 0.Centos7 优盘U盘安装以及解决安装时引导错误 1.CentOS7开启网卡,设置开机启用网卡 2.CentOS7 修改静态IP地址 3.CentOS7 下使用root免密码输入自动登 ...

  5. MUI 添加自定义图标(注意点)

    参考: https://blog.csdn.net/qq_39759115/article/details/79436606 注意: 1. 将这个原来的逗号改成分号 2. 这些图标的名字都可以改名字

  6. CSS3扫描动画效果

    .swiper-animate { position: absolute; width: 100%; height: 100%; left:; top:; z-index:; background: ...

  7. Skipping acquire of configured file ···doesn't support architecture 'i386' acquire of configured file

    系统更新的时候报错: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'http://rep ...

  8. android studio 模拟器不能使用的解决方案

    1.安装模拟器的时候 AS提示是 VT -x is disable 进入电脑的 bios 系统设置,怎么进入--> 在开机的时候点击F2(华硕电脑,不同电脑方式不同) --在“configura ...

  9. weblogic中配置数据源

    Weblogic数据源配置 一.配置数据源 1.点击数据源,进入数据源配置页面,点击新建后选择一般数据源 2.输入名称和jndi名称(两个输入一样即可)后点击下一步 3.选择驱动后点击下一步 4.输入 ...

  10. arr.sort()

    var ary = [12,2,0,15,32,125,52,63,45,24]; /* * sort实现原理 每一次拿出数组中的当前项和后一项,每一次这样的操作都会让传递的匿名函数执行一次,不仅执行 ...