# 高精度除法()-其他

## 高精度除法()

``````#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> a, c;
int b;

int div () {
int t = 0;
for (int i = a.size() - 1; i >= 0; i--) {
t = t * 10 + a[i];
c.push_back(t / b);
t %= b;
}
reverse(c.begin(), c.end());
while (c.size() > 1 && c.back() == 0) c.pop_back();
return t;
}

int main() {
string x;
cin >> x >> b;

for (int i = x.size() - 1; i >= 0; i--) a.push_back(x[i] - '0');

int t = div ();
for (int i = c.size() - 1; i >= 0; i--) cout << c[i];
cout << endl << t << endl;
return 0;
}
``````
————————

``````#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> a, c;
int b;

int div () {
int t = 0;
for (int i = a.size() - 1; i >= 0; i--) {
t = t * 10 + a[i];
c.push_back(t / b);
t %= b;
}
reverse(c.begin(), c.end());
while (c.size() > 1 && c.back() == 0) c.pop_back();
return t;
}

int main() {
string x;
cin >> x >> b;

for (int i = x.size() - 1; i >= 0; i--) a.push_back(x[i] - '0');

int t = div ();
for (int i = c.size() - 1; i >= 0; i--) cout << c[i];
cout << endl << t << endl;
return 0;
}
``````