Vijos P1201 high and low level exchange

Source: Internet
Author: User
P1201 high and low bit Exchange Accepted tag: analog Description

A positive integer less than 2^32 is given. This number can be represented by a 32-bit binary number (less than 32 bits with 0 complement). We call the first 16 bits of the binary number "high" and the last 16 bits "low." We can get a new number by exchanging its high and low positions. How much this new number is (in decimal notation).

For example, the number 1314520 is represented by a binary representation of 0000 0000 0001 0100 0000 1110 1101 1000 (added 11 leading 0 topping for 32 bits), where the first 16 bits are high, i.e. 0000 0000 0001 0100; the latter 16 bits are low, i.e. 0000 1 110 1101 1000. Swapping its high and low positions, we got a new binary number 0000 1110 1101 1000 0000 0000 0001 0100. It is the decimal 249036820.
format Input Format

A positive integer output format that is less than 2^32

The new number output example 1 sample input 1[copy]

1314520
sample Output 1[copy]
249036820
Limit

Each test point 1s source

CQBZ Noip Club



Don't think about what to write immediately when you meet the question. Sometimes there may be a simpler and easier way.

I think most of the students at the beginning to see this problem, think of the use of array storage and other methods of it!

Between AC and WA may be just a flash of a simple idea.


#include <iostream>
using namespace std;
int main ()
{
    unsigned int n;
    cin>>n;
    cout<< (n<<16) + (n>>16) <<endl;
    return 0;
}




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.