vector<int> div(vector<int>& A, int B, int& r){ vector<int> 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; }
intmain(){ string a; int b, r = 0; cin >> a >> b; vector<int> A; for(int i = a.length() - 1; i >= 0; --i) A.push_back(a[i] - '0'); vector<int> res = div(A, b, r); for(int i = res.size() - 1; i >= 0; --i) printf("%d", res[i]); printf("\n%d", r); }