提交时间:2024-08-20 16:28:15

运行 ID: 169343

#include<bits/stdc++.h> using namespace std; typedef pair<int,int> PII; class BigInt:public vector<int>{ public: BigInt(int x); void operator*=(int x); void operator/=(int x); BigInt operator/(int x); bool operator<(const BigInt&)const; bool operator>(const BigInt&)const; private: void process_digit();}; ostream &operator<<(ostream &out,const BigInt&a){ for(int i=a.size()-1;i>=0;i--){ cout<<a[i];} return out;} BigInt::BigInt(int x){ push_back(x); process_digit();} void BigInt::process_digit(){ for(int i=0;i<size();i++){ if(at(i)<10)continue; if(i+1==size())push_back(0); at(i+1)+=at(i)/10; at(i)%=10; } while(size()>1&&at(size()-1)==0)pop_back(); return ;} void BigInt::operator*=(int x) { for (int i=0;i< size(); i++) at(i) *= x; process_digit(); return ;}