提交时间:2024-07-30 22:23:05
运行 ID: 159748
# include <bits/stdc++.h> using namespace std ; int c2i ( char c ) { if ( c >= '0' && c <= '9' ) { return c - '0' ; } else { return c - 'A' + 10 ; } } char i2c ( int i ) { if ( i < 10 ) { return char ( '0' + i ) ; } else { return char ( 'A' + i - 10 ) ; } } long long m2t ( string s , int m ) { long long ans = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { ans *= m ; ans += c2i ( s [i] ) ; } return ans ; } string t2n ( long long x , int n ) { string s = "" ; while ( x != 0 ) { int a = x % n ; x = ( x - ( x % n ) ) / n ; s = i2c ( a ) + s ; } return s ; } void jz ( ) { string s ; int a , b ; while ( cin >> a >> s >> b ) { long long mid = m2t ( s , a ) ; cout << t2n ( mid , b ) << endl ; } } int main ( ) { jz ( ) ; }