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 ...
随机推荐
- 配置tomcat https的步骤
keytool -genkey -v -alias tomcat -keyalg RSA -keystore D:\tomcat.keystore -validity 36500 keytool -g ...
- JAVA解析EXCEL(2003和2007)
本文参考: http://wenku.baidu.com/view/707f07d95022aaea998f0fd1.html http://surfingforrest.iteye.com/blog ...
- Cobbler安装配置简单使用
安装Cobbler [root@linux-node3 ~]# yum -y install epel-release [root@linux-node3 ~]# yum -y install cob ...
- hibernate 学习 五 hibernate核心接口
一 Configuration接口 Configuration对象只存在于系统的初始化阶段.配置相关. 配置文件可以使用默认的路径,也可以指定路径. Configuration config = ne ...
- StarUML中时序图
StarUML中时序图 在看时序图的例子的时候,发现有些的时序图上有小人的图标,可是一些UML工具却没有找到小人的图标,这让我很闹心,一直没解决,今天终于将该问题给解决了.解决这个问题来自于网上的一个 ...
- javamail - 发件、收件(SSL连接)
需要的包:mail.jar jsse.jar(说明:jsse.jar是jre自带的,如果jdk1.5及以下需要Java Activation Framework框架的activation.jar) ...
- 为什么用思科里面的设备第一次ping的时候总会丢一个包呢?
大家搞计算机的不用讲,肯定都玩过网络吧? 比如一些思科,华为,华三这些模拟器,你们总会当你第一次用某个设备去ping某个设备的时候第一包总会被丢弃. 但我相信很多人都不知道为啥 会丢弃. 今天小 ...
- JAVA企业级开发-session,cookie(13)
一. jsp jsp: java server pager .java动态生成网页的一门技术 使用servlet生成网页时候遇到的问题,为什么使用jsp? 在servlet里面书写htm ...
- gSoap传输二进制数据
最近使用gSoap传输二进制数据,遇到问题.gSoap不能一次传输二进制数据.所以使用分包传送. struct xsd_DwgInfo { ];//分包大小 int m_nReadSize;// bo ...
- 2013 Noip提高组 Day2
3288积木大赛 正文 题目描述 春春幼儿园举办了一年一度的“积木大赛”.今年比赛的内容是搭建一座宽度为n的大厦,大厦可以看成由n块宽度为1的积木组成,第i块积木的最终高度需要是hi. 在搭建开始之前 ...