2 solutions
-
1
#include<bits/stdc++.h> using namespace std; long long a,c[105],l; long long ks=1,res; char s[105]; int main(){ cin>>a; cin>>s; l=strlen(s); for(long long i=1;i<=l;i++) if(s[l-i]<='9') c[i]=s[l-i]-48; else c[i]=s[l-i]-55; for(long long i=1;i<=l;i++){ res+=c[i]*ks; ks*=a; } cout<<res; } -
1
#include <bits/stdc++.h> using namespace std; int jz;//进制 string rs;//r数字 int ds = 0;//十进制数字 string zh = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int rcm = 1;//r进制的幂 int main() { cin>>jz>>rs; reverse(rs.begin(),rs.end());//将rs倒序 for(int i = 0; i < rs.size();i++) { //将当前的字符转化为数字 int p = zh.find(rs[i]); ds += p * rcm;//进制的i次方 rcm *= jz; } cout<<ds<<endl; return 0; }
- 1
Information
- ID
- 4636
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 3
- Tags
- # Submissions
- 34
- Accepted
- 27
- Uploaded By