305375: CF1017B. The Bits
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
The Bits
题意翻译
手工翻译qwq,可能掺杂个人情感,但保证题目含义不变。 # 题目描述 Rudolf正在去城堡的路上。在大门前,保安问了他一个问题: 已知两个长度为$n$的二进制数$a,b$。你可以任意选择$a$中的两个二进制位,然后把上面的数字调换位置。问题是,有多少中不同的操作,可以生成一个与原来不同的$a\;|\;b$? 换句话说,令$c=a\;|\;b$,你能找到多少种操作,使得更改后的$a$满足$a'\;|\;b \ne c$? 其中$|$表示“按位或”运算。如$(01010)_2\;|\;(10011)_2=(11011)_2$ # 输入格式 输入的第一行包含一个整数$n$。其中$2\leqslant n \leqslant 10^5$ 后两行分别描述$a, b$。 # 输出格式 输出包含一个整数,表示交换的方案数。题目描述
Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question: Given two binary numbers $ a $ and $ b $ of length $ n $ . How many different ways of swapping two digits in $ a $ (only in $ a $ , not $ b $ ) so that bitwise OR of these two numbers will be changed? In other words, let $ c $ be the bitwise OR of $ a $ and $ b $ , you need to find the number of ways of swapping two bits in $ a $ so that bitwise OR will not be equal to $ c $ . Note that binary numbers can contain leading zeros so that length of each number is exactly $ n $ . [Bitwise OR](https://en.wikipedia.org/wiki/Bitwise_operation#OR) is a binary operation. A result is a binary number which contains a one in each digit if there is a one in at least one of the two numbers. For example, $ 01010_2 $ OR $ 10011_2 $ = $ 11011_2 $ . Well, to your surprise, you are not Rudolf, and you don't need to help him $ \ldots $ You are the security staff! Please find the number of ways of swapping two bits in $ a $ so that bitwise OR will be changed.输入输出格式
输入格式
The first line contains one integer $ n $ ( $ 2\leq n\leq 10^5 $ ) — the number of bits in each number. The second line contains a binary number $ a $ of length $ n $ . The third line contains a binary number $ b $ of length $ n $ .
输出格式
Print the number of ways to swap two bits in $ a $ so that bitwise OR will be changed.
输入输出样例
输入样例 #1
5
01011
11001
输出样例 #1
4
输入样例 #2
6
011000
010011
输出样例 #2
6