Description

大電神溜溜球有一天在冥想時發現可以用純位元運算實作加法。但你不會冥想,所以就去問他:到底要怎麼做呢?

原來是這樣的:首先,把你要加的兩個數字 $a_0$ 和 $b_0$ 每個位元做 AND,為要進位的部分,左移進位後得到 $a_1$;同時也對他們做 XOR,為沒有要進位的剩下部分 $b_1$。接著把 $a_1$ 再和 $b_1$ 做加法……一直重複到 $a_n$ 等於 $0$ 為止。

理解後的你感覺實力大增,現在隨便給你兩個數字,你都能直接想像到它們用位元做加法的過程長什麼樣子了!

Input Format

第一行有兩個數字為 $a_0$ 和 $b_0$
接著依照題目指定方式操作,並依序輸出目前的 $a_i$、$b_i$ 的二進位數值 (16 位)

條件:

$0 \le a_0 < 2^{16}$
$0 \le b_0 < 2^{16} - a_0$

Output Format

詳見範例測資

Sample Input 1

3 1

Sample Output 1

A0: 0000000000000011
B0: 0000000000000001
A1: 0000000000000010
B1: 0000000000000010
A2: 0000000000000100
B2: 0000000000000000
A3: 0000000000000000
B3: 0000000000000100

Sample Input 2

37 11

Sample Output 2

A0: 0000000000100101
B0: 0000000000001011
A1: 0000000000000010
B1: 0000000000101110
A2: 0000000000000100
B2: 0000000000101100
A3: 0000000000001000
B3: 0000000000101000
A4: 0000000000010000
B4: 0000000000100000
A5: 0000000000000000
B5: 0000000000110000

Hints

位元 AND 運算子為 &、XOR 運算子為 ^
左移和右移分別為 <<>>

Problem Source

冥想

TopCoder


$\texttt{<script>alert(":3");</script>}$

User's AC Ratio

100.0% (1/1)

Tags

Problem Setter

Created by

Subtasks

No. Testdata Range Constraints Score
1 0~1 範例測資 20
2 2~5 80

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1
1 1000 65536 65536 1
2 1000 65536 65536 2
3 1000 65536 65536 2
4 1000 65536 65536 2
5 1000 65536 65536 2