You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
496 B
25 lines
496 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
const int N = 1e5 + 10;
|
|
int a[N], al, r;
|
|
void div(int a[], int &al, int b, int &r) {
|
|
r = 0;
|
|
for (int i = al; i >= 1; i--) {
|
|
r = r * 10 + a[i];
|
|
a[i] = r / b;
|
|
r %= b;
|
|
}
|
|
while (al > 1 && !a[al]) al--;
|
|
}
|
|
int main() {
|
|
int n;
|
|
string x;
|
|
cin >> n >> x;
|
|
for (int i = x.size() - 1; i >= 0; i--) a[++al] = x[i] - '0';
|
|
div(a, al, n, r);
|
|
cout << r << endl;
|
|
return 0;
|
|
}
|