思路:

模拟。
实现:

 #include <iostream>
using namespace std;
const int MOD = ;
char a[], b[];
int sum[];
int main()
{
int n, m;
while (cin >> n >> m)
{
for (int i = n - ; i >= ; i--) cin >> a[i];
for (int i = m - ; i >= ; i--)
{
cin >> b[i];
sum[i] = sum[i + ] + b[i] - '';
}
long long ans = , pw = ;
for (int i = ; i < n; i++)
{
if (a[i] == '')
ans = (ans + (sum[i] * pw) % MOD) % MOD;
pw = pw * % MOD;
}
cout << ans << endl;
}
return ;
}

CF1066E 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. codefores 1066 E. Binary Numbers AND Sum

    这个题吧 你画一下就知道了 就拿这个例子来讲 4 5100110101 对于b串的话第5位只会经过a串的第4位,b串的第4位会经过a串的第3位和第4位.....b串的第1和第2位会经过a串的每一位 由 ...

  4. E. Binary Numbers AND Sum

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

  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 黑帽子第二章运行截图

  2. Swift 控制语句

    Control Flow指的是『逻辑控制语句』,包括if.if-else.for.for-in.while.do-while.switch等.其中大部分和OC中差不多,但Swift在某些方便增强了控制 ...

  3. Java应用架构设计模块化模式与OSGI摘录

    在Java中,最适合模块化的单元就是Jar文件. 代码层面我们关注的太多了,熟练的开发人员现在很少争论使用模式的好处,也不再识别哪个模式适合当前需要,因为都能够本能地使用各种设计原则和模式,从GoF的 ...

  4. bzoj 2238 Mst——树链剖分

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2238 一条非树边可以对一条链的树边产生影响.注意是边,所以把边下放到点上,只要跳 top 时 ...

  5. phpStorm的远端部署

    首先远端服务器的路径: /var/www -rwxrwxrwx jiangzhaowei jiangzhaowei 6月 index.html* lr-xr-xr-x root root 2月 php ...

  6. JAVA 内部类 (三)实例

    为什么要用内部类:控制框架 一个“应用程序框架”是指一个或一系列类,它们专门设计用来解决特定类型的问题.为应用应用程序框架,我们可从一个或多个类继承,并覆盖其中的部分方法.我们在覆盖方法中编写的代码用 ...

  7. 读取关联数据(EF Core2.1.1)

    对象-关系映射框架比如EF有三种 方式使用 模型中的导航属性来加载关联数据. 一..Lazy Loading.(关联数据在访问导航属性时被透明的加载,不需要特别的代码,自动的加载) 当一个实体第一次读 ...

  8. Kefa and Watch

    题意: 维护一个长度为n的字符串,两种操作: 1.将 [l,r] 的字符变为 c 2.询问 d 是否为 $S(l,r)$ 的周期 解法: 首先分析如何令 [l,r] 的周期为d,利用循环串的性质得: ...

  9. jquery table表格 获取选中的某一行和某一列的值

    table class="table table-hover" id="test123"> <tr> <th width="4 ...

  10. Unity 2D骨骼动画2:创建真实动画

    http://bbs.9ria.com/thread-401781-1-1.html 在这个系列,我们将关注Unity引擎提供的基于骨骼动画工具.它的主要思想是为了把它应用到你自己的游戏来介绍和教基本 ...