'commit'
This commit is contained in:
27
GESP/Level4/GESP202309/4_1.cpp
Normal file
27
GESP/Level4/GESP202309/4_1.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
/*
|
||||
2
|
||||
8 1362
|
||||
16 3F0
|
||||
*/
|
||||
int main() {
|
||||
int T;
|
||||
cin >> T;
|
||||
while (T--) {
|
||||
int k;
|
||||
string s;
|
||||
int res = 0;
|
||||
cin >> k >> s; // k进制,s是k进制的一个数
|
||||
for (int i = 0; i < s.size(); i++) {
|
||||
int x = 0;
|
||||
if (s[i] >= 'A')
|
||||
x = s[i] - 'A' + 10;
|
||||
else
|
||||
x = s[i] - '0';
|
||||
res = res * k + x;
|
||||
}
|
||||
cout << res << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user