提交时间:2024-08-19 17:19:14

运行 ID: 167748

#include<bits/stdc++.h> using namespace std; int n,ansn; string a,b,ans; int change_ten(string s){ int num=0; int now; for(int i=0;i<s.size();i++){ now=s[i]; if(now>='A'&&now<='Z') now-=55; else if(now>='0'&&now<='9') now-=48; num+=pow(n,s.size()-1-i)*now; } return num; } void change_n(int s){ int str[100005]; int now,i=1; while(s!=0){ int y=s%n; s/=n; str[i]=y; i++; } for(int j=i-1;j>=1;j--){ cout<<str[j]; } return; } int main(){ cin>>n; cin>>a>>b; ansn=change_ten(a)+change_ten(b); change_n(ansn); return 0; }