Multi-school joint training exercise G. Digital logic exercises (general calculation) __ Simple Math

Source: Internet
Author: User
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 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.