题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
class BigInt{
public:
vector[HTML_REMOVED] v;
BigInt(){}
BigInt(const string& x){
for(unsigned i=0; i<x.size(); i++)
v.push_back(x.at(i) - '0');
}
void operator=(const string& x){
v.clear();
for(unsigned i=0; i<x.size(); i++)
v.push_back(x.at(i) - '0');
}
void operator=(const BigInt& x){
v = x.v;
}
BigInt& operator+(const BigInt& x){
vector<int> temp;
int add = 0;
int i = v.size()-1;
int j = x.v.size()-1;
while(i>=0 && j>=0){
temp.push_back((v[i]+x.v[j]+add)%10);
add = (v[i]+x.v[j]+add)/10;
i--, j--;
}
while(i>=0){
temp.push_back((v[i]+add)%10);
add = (v[i]+add)/10;
i--;
}
while(j>=0){
temp.push_back((x.v[j]+add)%10);
add = (x.v[j]+add)/10;
j--;
}
if(add)
temp.push_back(add);
reverse(temp.begin(), temp.end());
v = temp;
return *this;
}
friend istream& operator>>(istream& cin, BigInt& x);
friend ostream& operator<<(ostream& cout, const BigInt& x);
};
ostream& operator<<(ostream& cout, const BigInt& x){
for(vector[HTML_REMOVED]::const_iterator it=x.v.begin(); it!=x.v.end(); it++)
cout << *it;
return cout;
}
istream& operator>>(istream& cin, BigInt& x){
string t;
cin >> t;
x = t;
return cin;
}
int main(){
BigInt a;
BigInt b;
cin >> a >> b;
cout << a+b << endl;
return 0;
}
blablabla
```