UVa 10469 To Carry or not to Carry (异或)
2013-10-19 12:10
453 查看
10469 - To Carry or not to Carry
Time limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1410
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 take2
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
0+0=0
0+1=1
1+0=1
1+1=0
这不异或么。。
完整代码:
/*0.015s*/ #include<cstdio> int main() { int a, b; while (~scanf("%d%d", &a, &b)) printf("%d\n", a ^ b); return 0; }
相关文章推荐
- UVa 10469 - To Carry or not to Carry
- To xor or not to xor 高斯消元求异或
- UVA - 10273 Eat or Not to Eat?
- sgu275--To xor or not to xor(高斯消元问题5,子序列异或的最大和)
- UVa10273 Eat or Not to Eat?
- UVA 1541 - To Bet or Not To Bet(概率递推)
- UVA - 10273 Eat or Not to Eat?
- UVA - 10273 Eat or Not to Eat? 暴力
- UVA 10273 - Eat or Not to Eat?(暴力)
- uva 10273 Eat or Not to Eat?
- UVA - 1541 To Bet or Not To Bet (DP+概率)
- uva 10273 Eat or Not to Eat?
- uva 10273 Eat or not to Eat?
- UVA 10273 Eat or not to Eat?
- Eat or Not to Eat? - UVa 10273 暴力
- UVA10469 To Carry or not to Carry【数字逻辑运算】
- sgu275:To xor or not to xor(最大异或和)
- UVA 1541 - To Bet or Not To Bet(概率递推)
- uva 1541 - To Bet or Not To Bet(记忆化+概率)
- UVA 10273 Eat or Not to Eat?