Codeforces Round 502 (in memory of Leopoldo Taravilse, Div. 1 + Div. 2)
B
The Bits
Codeforces
1200
原题
← AC →
翻译中…

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 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.

翻译中…

Input

翻译中…

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$.

翻译中…

Output

翻译中…

Print the number of ways to swap two bits in $a$ so that bitwise OR will be changed.

翻译中…

Note

翻译中…

In the first sample, you can swap bits that have indexes $(1, 4)$, $(2, 3)$, $(3, 4)$, and $(3, 5)$.

翻译中…

In the second example, you can swap bits that have indexes $(1, 2)$, $(1, 3)$, $(2, 4)$, $(3, 4)$, $(3, 5)$, and $(3, 6)$.

翻译中…

样例

Input #1
5
01011
11001
Output #1
4
InputCopy OutputCopy
Input #2
6
011000
010011
Output #2
6
InputCopy OutputCopy
题目信息
题号
1017B
时间限制
2 s
内存限制
256 MB
标签
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。