|
@@ -42,8 +42,8 @@ struct BigInt{
|
|
|
inline BigInt(long long a) : signum(::signum(a)), data(1, std::abs(a)){}
|
|
|
inline BigInt(const std::initializer_list<uint64_t>& l) : data(l), signum(1){}
|
|
|
inline BigInt(std::initializer_list<uint64_t>&& l) : data(std::move(l)), signum(1){}
|
|
|
- template<typename Iterator>
|
|
|
- inline BigInt(Iterator begin, Iterator end) : data(begin, end), signum(1){}
|
|
|
+ template<typename InputIterator>
|
|
|
+ inline BigInt(InputIterator begin, InputIterator end) : data(begin, end), signum(1){}
|
|
|
std::deque<uint64_t>::iterator begin(){return data.begin();}
|
|
|
std::deque<uint64_t>::iterator end(){return data.end();}
|
|
|
std::deque<uint64_t>::reverse_iterator rbegin(){return data.rbegin();}
|
|
@@ -53,14 +53,14 @@ struct BigInt{
|
|
|
std::deque<uint64_t>::const_reverse_iterator rbegin()const{return data.rbegin();}
|
|
|
std::deque<uint64_t>::const_reverse_iterator rend()const{return data.rend();}
|
|
|
size_t size()const{return data.size();}
|
|
|
- auto cbegin(){return data.cbegin();}
|
|
|
- auto cend(){return data.cend();}
|
|
|
+ auto cbegin(){return data.cbegin();}
|
|
|
+ auto cend(){return data.cend();}
|
|
|
auto crbegin(){return data.crbegin();}
|
|
|
- auto crend(){return data.crend();}
|
|
|
- auto cbegin()const{return data.cbegin();}
|
|
|
- auto cend()const{return data.cend();}
|
|
|
+ auto crend(){return data.crend();}
|
|
|
+ auto cbegin()const{return data.cbegin();}
|
|
|
+ auto cend()const{return data.cend();}
|
|
|
auto crbegin()const{return data.crbegin();}
|
|
|
- auto crend()const{return data.crend();}
|
|
|
+ auto crend()const{return data.crend();}
|
|
|
inline bool isZero()const{
|
|
|
for(auto it = data.begin();it != data.end();it++){
|
|
|
if(*it)return false;
|
|
@@ -138,14 +138,13 @@ struct BigInt{
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
- inline BigInt multopp(const BigInt& o){
|
|
|
- BigInt result(size() + o.size() + 1,0);
|
|
|
- BigInt temp(size() + o.size() + 1,0);
|
|
|
+ inline BigInt mult(const BigInt& o){
|
|
|
+ BigInt result(size() + o.size(),0);
|
|
|
+ BigInt temp(size() + o.size(),0);
|
|
|
int p = 0;
|
|
|
for(auto it1 = rbegin();it1 != rend();it1++){
|
|
|
auto it = temp.rbegin();
|
|
|
lui carry = 0;
|
|
|
- bool flag = false;
|
|
|
for(auto it2 = o.rbegin();it2 != o.rend();it2++){
|
|
|
lui prod = ((lui)*it1) * (*it2);
|
|
|
prod += carry;
|