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 ...
随机推荐
- Cpython解释器下实现并发编程
一 背景知识 二 python并发编程之多进程 三 python并发编程之多线程 四 python并发编程之协程 五 python并发编程之IO模型 六 补充:paramiko模块 七 作业 一 背景 ...
- 网络通信实验(1)STM32F4 以太网简介
STM32F4 以太网简介 STM32F407 芯片自带以太网模块,该模块包括带专用 DMA 控制器的 MAC 802.3(介质访问控制)控制器,支持介质独立接口 (MII) 和简化介质独立接口 (R ...
- TZOJ 5694 区间和II(树状数组区间加区间和)
描述 给定n个整数,有两个操作: (1)给某个区间中的每个数增加一个值: (2)查询某个区间的和. 输入 第一行包括两个正整数n和q(1<=n, q<=100000),分别为序列的长度和操 ...
- Unity 3D 如何修改新建脚本中的 C# 默认创建的 Script 脚本格式
首先在Unity的安装路径下找到 Unity5\Editor\Data\Resources\ScriptTemplates路径的(81-C# Script-NewBehaviourScript.cs. ...
- SpringCloud微服务基础
1.传统项目架构 传统项目分为三层架构,将业务逻辑层.数据库访问层.控制层放入在一个项目中.适合于个人或者小团队开发,不适合大团队开发. 2.分布式项目架构(解耦方案) 根据业务需求进行拆分成N个子 ...
- gcc8.2安装__(沒有成功)
重要:https://gcc.gnu.org/install/prerequisites.html 官方安装所需要的工具文档 还有就是这篇文章 http://blog.51cto.com/2716 ...
- js简单的注册页面
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- .net webapi 接收 xml 格式数据的三种情况
webapi 接收 xml 的三种方法 前段时间接到一个任务写一个小接口,要接收java端返回过来的短信xml数据. 刚拿到项目,我的第一想法是对方会以什么形式发送xml格式的数据给我呢,设想三种情况 ...
- 【转载】http proxy原理
最近使用Charles抓https包时,发现get和post方式的请求都能抓到,但是method为connect的就是抓不到.而且提示如下: You may need to configure you ...
- HTML 中使用 JavaScript
在 HTML 中插入 JavaScript 的主要方法,就是使用 <script> 元素, 浏览器会解释并执行其中的 JavaScript 代码. <script> 元素的属 ...