题目链接
题意:
思路:
基础位运算
1.<<左移几位 (在二进制上移位,如果超出了内存范围,自动溢出)
2.>>右移几位
用32位无符号的整形unsigned int 一是为了避免符号的影响,第二32位刚好符号题意,溢出的部分自动舍弃
AC代码
#include <bits/stdc++.h>
inline int read(){char c = getchar();int x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
const int N = 1e5 + 5;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const unsigned long long mod = 998244353;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
unsigned int n;
cin >> n;
cout << (n>>16)+(n<<16) << endl;//先在二进制上右移16位,超出的溢出,再同理左移16位
}