Files
python/GESP/Level4/GESP202309/manfenti.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

44 lines
976 B
C++

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 110;
int a[N], al;
string b[N];
int bl;
int main(){
LL n;
cin>>n;
if(n==0){
cout<<"00"<<endl;
return 0;
}
while(n){
int x = n % 2;
n /= 2;
a[++al] = x;
}
al = ceil(1.0 * al / 7) * 7;
for (int i = al; i > 1;i-=7){
string s = "";
for (int j = i; j > i - 7;j--)
s =s+ to_string(a[j]);
if(i == 7)
b[++bl] = "1"+s;
else
b[++bl] = "0"+s;
}
for (int i = bl;i>=1;i--){
for (int j = 0; j < b[i].size();j+=4){
int x = (b[i][j] - '0') * 8 + (b[i][j + 1] - '0') * 4
+ (b[i][j + 2] - '0') * 2 + (b[i][j + 3] - '0');
if(x>=10)
cout << char(x - 10 + 'A');
else
cout << x;
}
cout << " ";
}
return 0;
}