CF1066E Binary Numbers AND Sum
思路:
模拟。
实现:
#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的更多相关文章
- 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 ...
- codefores 1066 E. Binary Numbers AND Sum
这个题吧 你画一下就知道了 就拿这个例子来讲 4 5100110101 对于b串的话第5位只会经过a串的第4位,b串的第4位会经过a串的第3位和第4位.....b串的第1和第2位会经过a串的每一位 由 ...
- E. Binary Numbers AND Sum
链接 [http://codeforces.com/contest/1066/problem/E] 题意 给你长度分别为n,m的二进制串,当b>0时,对a,b,&运算,然后b右移一位,把 ...
- 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 ...
随机推荐
- [Codeforces 715C] Digit Tree
[题目链接] https://codeforces.com/contest/715/problem/C [算法] 考虑点分治 一条路径(x , y)合法当且仅当 : d(x) * 10 ^ dep(x ...
- js 字符串拼接、截取、查找...
函数:split() 功能:使用一个指定的分隔符把一个字符串分割存储到数组 例子: let str=”020-88888888-03”; let arr=str.split(”-”); console ...
- 2018值得选用的五个Linux服务器发行版
[IT168 编译]据最新统计,目前Linux发行版约有300种,几乎都可以作为服务器系统运行.在Linux早期,几乎所有发行版都是“万能”发行版,专门的Linux服务器发行版并不火热,到21世纪初, ...
- bzoj 3160 万径人踪灭 —— FFT
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3160 求出关于一个位置有多少对对称字母,如果 i 位置有 f[i] 对,对答案的贡献是 2^ ...
- poj1151 Atlantis——扫描线+线段树
题目:http://poj.org/problem?id=1151 经典的扫描线问题: 可以用线段树的每个点代表横向被矩形上下边分割开的每一格,这样将一个矩形的出现或消失化为线段树上的单点修改: 每个 ...
- AndroidStudio自动弹出Documentation
AndroidStudio自动弹出Documentation窗口 例如,在布局文件中添加 Button 标签 敲完 <Butotn 回车后就自动出现 Documentation窗口 那如何关闭自 ...
- htop 详细功能使用简介
一.htop 简介 This is htop, an interactive process viewer for Linux. It is a text-mode application (for ...
- atof,atoi,atol,strtod,strtol,strtoul
字符串处理函数 atof 将字串转换成浮点型数 atoi 字符串转换成整型数 atol 函数名: atol 功 能: 把字符串转换成长整型数 用 法: long atol(const char *np ...
- 妙味课堂史上最全的javascript视频教程,前端开发人员必备知识点,新手易学,拔高必备!!!
妙味课堂是北京妙味趣学信息技术有限公司旗下的IT前端培训品牌, 妙味课堂是一支独具特色的IT培训团队,妙味反对传统IT教育枯燥乏味的教学模式,妙味提供一种全新的快乐学习方法! 妙味js视教第一部分 ...
- 不能支持C++11的特性~,升级到4.8.2
一.简易安装 操作环境 CentOS6.5 64bit,原版本4.4.7,不能支持C++11的特性~,希望升级到4.8.2 不能通过yum的方法升级,需要自己手动下载安装包并编译 1.1 获取安装包并 ...