提交时间:2024-08-19 14:09:39

运行 ID: 166395

#include<bits/stdc++.h> using namespace std; long long a[105],m; long long mtoten(long long n){ long long sum=0,cnt=1; while(n>0){ long long s=n%10; n/=10; sum+=s*cnt; cnt*=m; } return sum; } void tentom(long long n){ long long cnt=0; while(n>0){ cnt++; a[cnt]=n%m; n/=m; } for(int i=cnt;i>=1;i--){ if(a[i]>9){ cout<<(char)(a[i]+55); } else{ cout<<a[i]; } } } int main(){ long long x,y; cin>>m>>x>>y; tentom(mtoten(x)+mtoten(y)); return 0; }