Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
159748 | 梁乃元 | K进制数转L进制数 | C++ | 通过 | 100 | 0 MS | 252 KB | 834 | 2024-07-30 22:23:05 |
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 ( ) ; }
exit code: 0, checker exit code: 0
exit code: 0, checker exit code: 0
exit code: 0, checker exit code: 0
exit code: 0, checker exit code: 0
exit code: 0, checker exit code: 0