题目描述
高精度除法
C++ 代码
#include <bits/stdc++.h>
using namespace std;
vector<int> vie(vector<int>&A,long long int b)
{
vector<int> C;
long long int r = 0;
for(int i = A.size() - 1;i >= 0;i--)
{
r = r*10 + A[i];
C.push_back(r / b);
r %= b;
}
reverse(C.begin(),C.end());
while(C.size() > 1 && C.back() == 0) C.pop_back();
return C;
}
int main()
{
string a;
vector <int> A;
long long int b;
cin >> a;
cin >> b;
for(int i = a.size() - 1;i >= 0 ;i--) A.push_back(a[i] - '0');
for(int i = vie(A,b).size() - 1;i >= 0 ;i--) cout << vie(A,b)[i];
return 0;
}