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.

41 lines
1.0 KiB

2 years ago
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
/**
* 9000000000 1000000000
* 使int使LL
*/
using namespace std;
/**
*
* @param A
* @param b
* @param r
* @return
*/
vector<LL> div(vector<LL> &A, LL b, LL &r) {
vector<LL> C;
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;
LL b, r;
cin >> a >> b;
vector<LL> A, C;
for (int i = a.size() - 1; i >= 0; i--)A.push_back(a[i] - '0');
C = div(A, b, r);
for (int i = C.size() - 1; i >= 0; i--)printf("%d", C[i]);
// printf("\n%d", r);
return 0;
}