#379. 高低位交换
高低位交换
No testdata at current.
题目描述
给出一个小于 $2^{32}$ 的正整数。 这个数可以用一个 32 位的二进制数表示(不足 32 位用 0 补足)。 我们称这个二进制数的前 16 位为“高位”,后 16 位为“低位”。 将它的高低位交换,我们可以得到一个新的数。 试问这个新的数是多少(用十进制表示)。
例如,数 1314520 用二进制表示为 0000 0000 0001 0100 0000 1110 1101 1000
(添加了 11 个前导 0 补足为 32 位),其中前 16 位为高位,即 0000 0000 0001 0100
; 后 16 位为低位,即 0000 1110 1101 1000
。 将它的高低位进行交换,我们得到了一个新的二进制数 0000 1110 1101 1000 0000 0000 0001 0100
。 它即是十进制的 249036820。
输入格式
一个小于 $2^{32}$ 的正整数。
输出格式
将新的数输出。
示例
输入1:
<button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button>1314520
输出1:
<button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button>249036820
提示
将给定的数转换为二进制形式,然后将前 16 位和后 16 位交换,再将交换后的二进制数转换为十进制表示。