43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
#include <cstring>
|
|
#include <iostream>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
int n, a[101] = { 0 }, b[101] = { 0 }, c[201] = { 0 }, lena, lenb, lenc = 0;
|
|
string a1, b1;
|
|
cin >> n >> a1 >> b1;
|
|
lena = a1.size();
|
|
lenb = b1.size();
|
|
for (int i = 0; i < lena; i++) {
|
|
if (a1[i] >= 'A') {
|
|
a1[i] = a1[i] - 'A' + '9' + 1;
|
|
}
|
|
a[lena-i-1] = a1[i] - '0';
|
|
}
|
|
for (int i = 0; i < lenb; i++) {
|
|
if (b1[i] >= 'A') {
|
|
b1[i] = b1[i] - 'A' + '9' + 1;
|
|
}
|
|
b[lenb-1-i] = b1[i] - '0';
|
|
}
|
|
for (int i = 0; i < lena; i++) {
|
|
for (int j = 0; j < lenb; j++) {
|
|
c[i + j] += a[i] * b[j];
|
|
c[i + j + 1] += c[i + j] / n;
|
|
c[i + j] %= n;
|
|
}
|
|
}
|
|
int len = lena + lenb;
|
|
while(c[len-1]==0&&len>0){
|
|
len--;
|
|
}
|
|
while (len > 0) {
|
|
--len;
|
|
if (c[len] > 9) {
|
|
char c1 = c[len] - 10 + 'A';
|
|
cout << c1;
|
|
} else {
|
|
cout << c[len];
|
|
}
|
|
}
|
|
} |