本文整理汇总了C++中bigint::size方法的典型用法代码示例。如果您正苦于以下问题:C++ bigint::size方法的具体用法?C++ bigint::size怎么用?C++ bigint::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bigint
的用法示例。
在下文中一共展示了bigint::size方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool operator<(const bigint &b)const{
const bigint &a(*this);
if(a.size()==b.size()){
for(int i=b.size()-1;i>=0;i--){
if(a[i]==b[i])continue;
return a[i]<b[i];
}
}
return (a.size()<b.size());
}
示例2: multiply
void multiply(bigint &x, bigint &y, bigint &z) {
z.resize(x.size() + y.size(), 0);
for (int i = 0; i < x.size(); i++) {
for (int j = 0; j < y.size(); j++) {
z[i+j] += x[i] * y[j];
z[i+j+1] += z[i+j]/10;
z[i+j] = z[i+j]%10;
}
}
}
示例3:
bool operator<(const bigint &lhs, const std::deque<int> &rhs)
{
if (lhs.size() != rhs.size()) return lhs.size() < rhs.size();
if (lhs[0] != rhs.front()) return lhs[0] < rhs.front();
std::deque<int>::const_iterator cit = rhs.begin() + 1;
int i = 1;
for (; cit != rhs.end(); ++cit, ++i)
if (lhs[i] != *cit) return lhs[i] < *cit;
return false;
}
示例4: z
bigint operator*(bigint const& x, bigint const& y) {
bigint z(x.size() + y.size());
for (size_t i = 0; i < x.size(); ++i)
for (size_t j = 0; j < y.size(); ++j) {
z[i + j] += x[i] * y[j];
z[i + j + 1] += z[i + j] / 10;
z[i + j] %= 10;
}
return z;
}
示例5: divmod
inline void divmod(const bigint &a,int b,bigint &div,int &mod){
div.resize(a.size());
long long l=0;
for(int i=a.size()-1;i>=0;--i){
l*=BASE;
l+=a[i];
div[i]=l/b;
l%=b;
}
if(div[div.size()-1]==0 and div.size()>1)
div.resize(div.size()-2);
mod=int(l);
}
示例6: assert
inline bigint operator-(const bigint &a,const bigint &b){
assert(b<a or a==b);
bigint c ;
c.resize(a.size());
long long l=0;
for(int i=0;i<a.size();++i){
l+=a[i] ;
l-=(i<b.size())?b[i]:0;
if(l<0)l+=BASE;
c [i]=l%BASE;
l/=BASE ;
}
return c ;
}
示例7: suma
//suma a+b?BASE坘
inline bigint suma(const bigint &a,const bigint &b,int k){
bigint c;
int size=max(a.size(),b.size()+k);
c.resize(size);
long long l=0;
for(int i=0;i<size;++i){
l+=i<a.size()?a[i]:0;
l+=(k<=i and i<k+b.size())?b[i-k]:0;
c[i]=l%BASE;
l/=BASE;
}
c.adddigit(int (l));
return c;
}
示例8: to_string
void to_string(bigint &n, string &s) {
bool start = false;
for (int i = n.size()-1; i >= 0; i--) {
if (!start && n[i] != 0) start = true;;
if (start) s += (char)(n[i] + '0');
}
}
示例9: producto1
bigint producto1(const bigint &x, const bigint &y) {
int n;
bigint a, b, c, d;
if (x.size() > y.size())
n = x.size();
else
n = y.size();
if (n < UMBRAL)
return x * y;
else {
a = x.digits(x.size() / 2, x.size() - 1);
b = x.digits(0, x.size() / 2 - 1);
c = y.digits(y.size() / 2, y.size() - 1);
d = y.digits(0, y.size() / 2 - 1);
return (producto1(a, c) * elevar10(n)) + ((producto1(a, d) + producto1(b, c)) * elevar10(n / 2)) + producto1(b, d);
}
}