1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; int main(){ string s; int a,b,i,j; cin>>s>>a>>b; if(s=="0") { cout<<"("<<0<<")"<<b; return 0; } //转成十进制 long long r = 0,x; for(i=0;i<s.size();i++) { if(s[i]>='0' && s[i]<='9') x = s[i]-'0'; else x = s[i]-'a'+10; for(j=1;j<=s.size()-i-1;j++) { x = x * a; } r = r + x; } string t =""; while(r!=0) { if(r%b>=10) t = char(r%b-10+'a') + t ; else t = char(r%b+'0') + t; r = r/b; } cout<<"("<<t<<")"<<b; return 0; }
- 1
Information
- ID
- 10592
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By