AcWing 5066. 十进制加密
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e6+10;
int t,n,m,k,l,r,op,y;
int f[N];
bool flag;
string rules = "xxxxppppxxxxeeeexxxxeeeexxxxeeee";
ll X,E,P;
string res(32,'0');
void solve(){
cin>>n;
while(n){
res[m++] = '0'+n%2;
n/=2;
}
reverse(res.begin(),res.end());
for(int i = 0;i<32;i++){
if(res[i]=='0')continue;
if(rules[i]=='x')X+=(1<<(32-1-i));
if(rules[i]=='e')E+=(1<<(32-1-i));
if(rules[i]=='p')P+=(1<<(32-1-i));
}
cout<<(X+(E<<8)+(P>>24));
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}