Topic Description
The original code, the inverse code, the complement is the same, are positive numbers themselves.
For negative numbers:
The original code is the symbol bit is 1, the numerical part takes the absolute value the binary system.
The counter code is the sign bit is 1, the other bit is the original code to take the counter.
The complement is the sign bit is 1, the other bit is the original code to take the counter, is not bit plus 1.
Enter a 64bit decimal integer, output its original code, the inverse code, the complement of the 16 notation
input
There are multiple sets of data, one row for each set of data, a 64bit decimal integer containing positive and negative symbols and numeric values, as shown in the sample format.
The input guarantee has a unique source code, an inverse code, and a complement corresponding to it.
Output
Output of three 16 in each group, respectively, the original code, the inverse code, complement.
Sample Input
+1
-1
+10086
-2333333
Sample Output
0x0000000000000001
0x0000000000000001
0x0000000000000001
0x8000000000000001
0xfffffffffffffffe
0xffffffffffffffff
0x0000000000002766
0x0000000000002766
0x0000000000002766
0x8000000000239a95
0xffffffffffdc656a
0xffffffffffdc656b
train of Thought
For a positive number, its original inverse complement is the same, directly in accordance with the format output.
For negative numbers, we can use 264 2^{64} and the original number of some operations to get the original inverse complement, because it involves a large number, originally wanted to write in Java, but found that can be submitted in Python, so thousands of C + + in the emergence of a special case for me.
PS: input is likely to have a 0 situation, and its original inverse complement is not equal to +0.
AC Code
while true:try:t = raw_input () If Len (T.strip ()) = = 0:continue if T = = '-0 ': print ' 0x8000000000000000 ' print ' 0xffffffffffffffff ' print ' 0x
0000000000000000 ' Continue t = Int (t) if T >= 0:print '% #018x '% t
print '% #018x '% t print '% #018x '% t else:print '% #018x '% (0x8000000000000000 |-t)
print '% #018x '% (2 * * 64-1 + t) print '% #018x '% (2 * * 64-1 + t + 1) except Eoferror: Break