Files
python/GESP/Level4/GESP202309/4_1.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

27 lines
460 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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