Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
159673 梁乃元 K进制数转L进制数 C++ 通过 100 0 MS 256 KB 834 2024-07-30 16:48:10

Tests(5/5):


# 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 ( ) ; }


测评信息: