AcWing 3616. 进制转换
原题链接
简单
#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,x,y;
int f[N];
bool flag;
int siz;
string str;
void solve(){
cin>>str;
int siz = str.size();
for(int i = 0;i<siz;i++){
k = str[i]>='0'&&str[i]<='9' ?
str[i]-'0' : str[i]-'a'+10;
cout<<k<<" ";
m += k * pow(12,(siz-1-i));
}
cout<<"\n";
cout<<m;
cout<<"\n";
string st(32,'0');
while(m){
st[x++] = m%2+'0';
m/=2;
}
reverse(st.begin(),st.end());
cout<<(st.substr(0,8)+" "+st.substr(8,8)+" "+
st.substr(16,8)+" "+st.substr(24,8));
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}