vector int operator vector int const vector int int for int max size s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
vector <int> operator + (vector <int>& a,
const vector <int> &b){
int p = 0;
for (int i = 0; i < max(a.size(), b.size()) || p; ++i){
if (i >= a.size())
a.push_back(0);
a[i] += (i < b.size() ? b[i] : 0) + p;
p = a[i] / 10;
a[i] %= 10;
}
return a;
}
vector <int> operator *(const vector <int> &a,
const vector <int> &b){
int p;
vector <int> c(a.size() + b.size(), 0);
for (int j = 0; j < b.size(); ++j){
p = 0;
for (int i = 0; i < a.size() || p; ++i){
c[i + j] += (i >= a.size() ? 0 : a[i]) * b[j] + p;
p = c[i + j] / 10;
c[i + j] %= 10;
}
}
while (!c.back() && c.size() > 1)
c.pop_back();
return c;
}
bool bigger_then(long long a, long long b) {
if (a < 1e8 && b < 1e8)
return true;
vector<int> aa(0), bb(0);
while (a) {
aa.push_back(a % 10);
a /= 10;
}
while (b) {
bb.push_back(b % 10);
b /= 10;
}
if (aa.size() + bb.size() < 17)
return false;
vector<int> q = aa * bb;
if (q.size() < 19) {
return false;
}
else {
if (q.size() > 19)
return true;
for (int i = 0; i < 18; ++i) {
if (q[i] != 0)
return false;
}
if (q[18] != 1)
return false;
return true;
}
}