codefores 1066 E. Binary Numbers AND Sum
这个题吧
你画一下就知道了
就拿这个例子来讲
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的更多相关文章
- Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum
E. Binary Numbers AND Sum 题目链接:https://codeforces.com/contest/1066/problem/E 题意: 给出两个用二进制表示的数,然后将第二个 ...
- 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 ...
- E. Binary Numbers AND Sum
链接 [http://codeforces.com/contest/1066/problem/E] 题意 给你长度分别为n,m的二进制串,当b>0时,对a,b,&运算,然后b右移一位,把 ...
- CF1066E Binary Numbers AND Sum
思路: 模拟.实现: #include <iostream> using namespace std; ; ], b[]; ]; int main() { int n, m; while ...
- Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum (二进制,前缀和)
题意:有两个\(01\)字符串\(a\)和\(b\),每次让\(a\)和\(b\)进行与运算,将值贡献给答案,然后将\(b\)右移一位,直到\(b=0\). 题解:因为\(a\)不变,而\(b\)每次 ...
- 【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 ...
- 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 ...
- HDU-1390 Binary Numbers
http://acm.hdu.edu.cn/showproblem.php?pid=1390 Binary Numbers Time Limit: 2000/1000 MS (Java/Others) ...
- [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 ...
随机推荐
- step_by_step_记录deepin下curl安装过程
记录 deepin 下 curl 安装过程 wget https://curl.haxx.se/download/curl-7.55.1.tar.gz .tar.gz cd curl-/ ./conf ...
- Mybatis常用代码
以下使用的数据库是Mysql. Mybatis动态Sql: Mapper.xml如下: <select id="selectOrderList" resultMap=&quo ...
- python 获取list的下标
print(your_list.index('your_item')) #your_list为列表名称 your_item为需要修该的数据
- Windows 窗体
Windows系统,顾名思义,就是窗口系统,每一个程序都可以用窗口来展示,所以,为了展示窗口,需要多做一系列的工作,当然,也有纯控制台应用,就不用附带窗口了. 首先就是窗口程序的入口地址,与传统的in ...
- 后台商品搜索功能开发SQL
在做后台的商品搜索功能开发时遇到了一些问题记录下来 版本一 <select id="SelectByNameAndParentId resultMap="Base_resul ...
- 【Spring源码解析】—— 依赖注入结合SpringMVC Demo-xml配置理解
在IOC容器初始化的梳理之后,对依赖注入做一个总结,就是bean实例化的过程,bean的定义有两种方式,一种是xml文件配置,一种是注解,这里是对xml配置文件的依赖注入的介绍,后续对bean与该部分 ...
- CVTE C/C++开发工程师笔试题(一)
问题描述: 字符串组装. 现在需要将一些数据格式不同的数据组装成一个char型字符串输出,数据来源包含一个char型的字符串,一个short型的16进制数据: 举例: 假若定义如下2个变量: 1.ch ...
- java实验环境搭建,eclise下载与使用
一.1.官方下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html 下载后安装,默认安装即可. 2.在 wind ...
- How to change system keyboard keymap layout on CentOS 7 Linux
The easiest way to swap between keymaps and thus temporarily set keys to different language by use o ...
- AnjularJS 学习
一个不错的学习AnjularJS的网站,可以在线实践:http://www.runoob.com/angularjs/angularjs-tutorial.html