学到的
- c++的乘方运算 cmath库
- 字符串转数字int
C++代码
#include <iostream>
#include <cmath>
using namespace std;
int k;
string a,b;
int solve(string s)
{
int res = 0;
for(int i = 0, j = s.length() - 1;i < s.length(); i++,j--)
{
res += (s[i] - '0') * pow(k,j);
}
return res;
}
int main()
{
// 请在此输入您的代码
cin >> k >> a >> b;
cout << solve(a) * solve(b) << endl;
return 0;
}