問題一覧 > 通常問題

No.2323 Nafmo Does A+B

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 292
作問者 : Nafmo2 / テスター : dyktr_06 hikikomori sepa38
お気に入りにしたユーザー ProblemId : 9546 / 自分の提出
問題文最終更新日: 2023-05-17 23:56:49
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
MMA Contest 015 (順位表) の他の問題:

Problem Statement

Nafmo, a $2$nd-year undergraduate, was studying addition of base-$2$ numbers. He is trying to add the base-$2$ numbers $A$ and $B$ by column addition, computing in order from the lowest digit.
Being careless, Nafmo forgot to handle the carries at every digit and arrived at a wrong answer.

Given the base-$2$ numbers $A$ and $B$, convert the wrong answer computed by Nafmo to base $10$ and output it.

Here, ${X}_{(n)}$ denotes the base-$n$ representation of an integer $X$.

Input

$A_{(2)}$
$B_{(2)}$
  • $0 \leq A_{(10)},B_{(10)} < 2^{30}$
  • Both $A,B$ are base-$10$ positive integers written in base $2$
  • When $A,B$ are at least $1$, the first character of each is not $0$

Output

Convert the wrong answer computed by Nafmo to base $10$ and output it.

Sample

Sample 1
Input
10
100
Output
6

For clarity, let $A=010_{(2)}$.
Computing $A+B$ in base-$2$ notation gives the following.
$A+B=010+100=110$
There are no carries in this calculation, so the answer is $6$, which is $110$ converted to base $10$.

Sample 2
Input
111
111
Output
0

Looking at the $1$s place, we have $1+1=10$. However, Nafmo made the mistake of forgetting to add the carried $1$ to the $2$s place. Thus, the calculation at the $1$s place ended up as $1+1=0$.

Since he did the same for each place, the result of the column addition is $000$, and the answer converted to base $10$ is $0$.

Sample 3
Input
10100
1011
Output
31

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。