24h購物| | PChome| 登入
2012-03-31 10:06:21| 人氣1,582| 回應0 | 上一篇 | 下一篇

[UVA] 10469 - To Carry or not to Carry

推薦 0 收藏 0 轉貼0 訂閱站台

Problem G:  To Carry or not to Carry

Time Limit: 1 second
Memory Limit: 32 MB

6+9=15 seems okay. But how come 4+6=2?

You see, Mofiz had worked hard throughout his digital logic course, but when he was asked to implement a 32 bit adder for the laboratory exam, he did some mistake in the design part. After tracing the design for half an hour, he found his flaw!! He was doing bitwise addition but his carry bit always had zero output. Thus,
 4 = 00000000 00000000 00000000 00000100
+6 = 00000000 00000000 00000000 00000110
----------------------------------------
 2 = 00000000 00000000 00000000 00000010
Its a good thing that he finally found his mistake, but it was too late. Considering his effort throughout the course, the instructor gave him one more chance. Mofiz has to write an efficient program that would take 2 unsigned 32 bit decimal numbers as input, and produce an unsigned 32 bit decimal number as the output adding in the same was as his circuit does.

Input

In each line of input there will be a pair of integer separated by a single space. Input ends at EOF.

Output

For each line of input, output one line -- the value after adding the two numbers in the "Mofiz way".

Sample Input

4 6
6 9

Sample Output

2
15


#include <stdio.h>
int main() {
unsigned int a, b;
while(scanf("%u %u", &a, &b) == 2)
printf("%u\n", a^b);
return 0;
}
 

台長: Morris
人氣(1,582) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][LCS] 10405 - Longest Common Subsequence
此分類上一篇:[UVA] 11483 - Code Creator

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文