提交时间:2025-05-24 13:14:11
运行 ID: 323987
#include <bits/stdc++.h> using namespace std; string s; int main() { long long n,w; cin>>n>>w; char c; while(n>0){ if(w==2){ c=n%2+'0'; s=c+s; n=n/2; } if(w==8){ w=n%8; c=w+'0'; s=c+s; n=n/8; } if(w==16){ w=n%16; if(n<10){ c=w+'0'; }else{ c=w+'A'-10; } s=c+s; n=n/16; } } cout<<s; return 0; }