static
const
int
BASE
=
10
;
static
const
int
WIDTH
=
1
;
BigInteger
(
long
long
num
=
0
)
{
*
this
=
num
;
}
BigInteger
operator
=
(
long
long
num
)
s
.
push_back
(
num
%
BASE
)
;
BigInteger
operator
=
(
const
string
&
str
)
int
x
,
len
=
(
strr
.
length
(
)
-
1
) /
WIDTH
+
1
;
int
end
=
strr
.
length
(
)
-
i
*
WIDTH
;
int
start
=
max
(
0
,
end
-
WIDTH
)
;
sscanf
(
strr
.
substr
(
start
,
end
-
start
)
.
c_str
(
)
,
"%d"
,
&
x
)
;
BigInteger
operator
+
(
const
BigInteger
&
b
)
const
for
(
int
i
=
0
,
g
=
0
;;
i
++
)
if
(
g
==
0
&&
i
>=
s
.
size
(
)
&&
i
>=
b
.
s
.
size
(
))
if
(
i
<
b
.
s
.
size
(
))
c
.
s
.
push_back
(
x
%
BASE
)
;
BigInteger
operator
*
(
const
BigInteger
&
b
)
const
for
(
int
i
=
0
;
i
<
s
.
size
(
)
;
i
++
)
t
.
s
.
push_back
(
0
)
;
for
(
j
=
g
=
0
;;
j
++
)
if
(
j
>=
b
.
s
.
size
(
)
&&
g
==
0
)
if
(
j
<
b
.
s
.
size
(
))
x
+=
s
[
i
]
*
b
.
s
[
j
]
;
t
.
s
.
push_back
(
x
%
BASE
)
;
BigInteger
operator
*
(
const
int
&
b
)
const
BigInteger
operator
*
(
const
long
long
int
&
b
)
const
BigInteger
operator^
(
int
b
)
const
BigInteger
ans
=
1
,
base
=
*
this
;
BigInteger
operator
+=
(
const
BigInteger
&
b
)
const
bool
operator
<
(
const
BigInteger
&
b
)
const
if
(
b
.
flag
==
0
&&
b
.
flag
!=
flag
)
if
(
s
.
size
(
)
!=
b
.
s
.
size
(
))
return
s
.
size
(
)
<
b
.
s
.
size
(
)
;
for
(
int
i
=
s
.
size
(
)
-
1
;
i
>=
0
;
i
--
)
if
(
s
[
i
]
!=
b
.
s
[
i
])
return
s
[
i
]
<
b
.
s
[
i
]
;
bool
operator
>
(
const
BigInteger
&
b
)
const
{
return
b
<
*
this
;
}
bool
operator
<=
(
const
BigInteger
&
b
)
const
{
return
!
(
b
<
*
this
)
;
}
bool
operator
>=
(
const
BigInteger
&
b
)
const
{
return
!
(
*
this
<
b
)
;
}
bool
operator
!=
(
const
BigInteger
&
b
)
const
{
return
b
<
*
this
||
*
this
<
b
;
}
bool
operator
==
(
const
BigInteger
&
b
)
const
{
return
!
(
b
<
*
this
)
&&
!
(
*
this
<
b
)
;
}
BigInteger
operator
-
(
const
BigInteger
&
b
)
const
swap
(
A
,
B
)
;
c
.
flag
=
0
;
if
(
i
>=
A
.
s
.
size
(
)
&&
i
>=
B
.
s
.
size
(
))
if
(
i
<
B
.
s
.
size
(
))
c
.
s
.
push_back
(
x
)
;
if
(
c
.
s
.
back
(
)
==
0
)
vector
<
int
>
::
iterator
it
=
c
.
s
.
end
(
)
;
for
(
it
--
;
it
!=
c
.
s
.
begin
(
)
;
it
--
)
c
.
s
.
erase
(
it
,
c
.
s
.
end
(
))
;
c
.
s
.
push_back
(
0
)
;
BigInteger
operator
-
(
const
int
&
b
)
const
BigInteger
operator
-
(
const
long
long
int
&
b
)
const
BigInteger
operator
-=
(
const
BigInteger
&
b
)
const
{
return
*
this
-
b
;
}
BigInteger
operator
!
(
void
)
const
for
(
BigInteger
i
=
1
;
i
<=
*
this
;
i
+=
1
)
BigInteger
operator/
(
const
BigInteger
&
b
)
const
BigInteger
A
,
B
,
c
,
ans
;
A
.
flag
=
B
.
flag
=
c
.
flag
=
1
;
int
zero
=
(
A
.
s
.
size
(
)
-
b
.
s
.
size
(
))
;
B
.
s
.
insert
(
B
.
s
.
begin
(
)
,
zero
,
0
)
;
while
(
!
B
.
s
.
empty
(
)
&&
B
>=
b
)
c
.
s
.
push_back
(
x
)
;
B
.
s
.
erase
(
B
.
s
.
begin
(
))
;
if
(
!
c
.
s
.
empty
(
))
for
(
vector
<
int
>
::
reverse_iterator
it
=
c
.
s
.
rbegin
(
)
;
it
!=
c
.
s
.
rend
(
)
;
it
++
)
ans
.
s
.
push_back
(
*
it
)
;
ans
.
s
.
push_back
(
0
)
;
if
(
ans
.
s
.
empty
(
))
ans
.
s
.
push_back
(
0
)
;
if
(
ans
.
s
.
back
(
)
==
0
)
vector
<
int
>
::
iterator
it
=
ans
.
s
.
end
(
)
;
for
(
it
--
;
it
!=
ans
.
s
.
begin
(
)
;
it
--
)
ans
.
s
.
erase
(
it
,
ans
.
s
.
end
(
))
;
ostream
&
operator
<<
(
ostream
&
out
,
const
BigInteger
&
x
)
out
<<
x
.
s
.
back
(
)
;
for
(
int
i
=
x
.
s
.
size
(
)
-
2
;
i
>=
0
;
i
--
)
sprintf
(
buf
,
"%d"
,
x
.
s
[
i
])
;
for
(
int
j
=
0
;
j
<
strlen
(
buf
)
;
j
++
)
istream
&
operator
>>
(
istream
&
in
,
BigInteger
&
x
)