MathDB
Problems
Contests
National and Regional Contests
USA Contests
USA - College-Hosted Events
CMIMC Problems
2019 CMIMC
14
14
Part of
2019 CMIMC
Problems
(1)
2019 T14: Integer Overflow
Source:
1/27/2019
Consider the following function.
procedure
\textsc{M}(x)
<
s
p
a
n
c
l
a
s
s
=
′
l
a
t
e
x
−
b
o
l
d
′
>
i
f
<
/
s
p
a
n
>
0
≤
x
≤
1
\qquad<span class='latex-bold'>if </span>0\leq x\leq 1
<
s
p
an
c
l
a
ss
=
′
l
a
t
e
x
−
b
o
l
d
′
>
i
f
<
/
s
p
an
>
0
≤
x
≤
1
<
s
p
a
n
c
l
a
s
s
=
′
l
a
t
e
x
−
b
o
l
d
′
>
r
e
t
u
r
n
<
/
s
p
a
n
>
x
\qquad\qquad<span class='latex-bold'>return </span>x
<
s
p
an
c
l
a
ss
=
′
l
a
t
e
x
−
b
o
l
d
′
>
re
t
u
r
n
<
/
s
p
an
>
x
\qquad
return
\textsc{M}(x^2\bmod 2^{32})Let
f
:
N
→
N
f:\mathbb N\to\mathbb N
f
:
N
→
N
be defined such that
f
(
x
)
=
0
f(x) = 0
f
(
x
)
=
0
if \textsc{M}(x) does not terminate, and otherwise
f
(
x
)
f(x)
f
(
x
)
equals the number of calls made to \textsc{M} during the running of \textsc{M}(x), not including the initial call. For example,
f
(
1
)
=
0
f(1) = 0
f
(
1
)
=
0
and
f
(
2
31
)
=
1
f(2^{31}) = 1
f
(
2
31
)
=
1
. Compute the number of ones in the binary expansion of
f
(
0
)
+
f
(
1
)
+
f
(
2
)
+
⋯
+
f
(
2
32
−
1
)
.
f(0) + f(1) + f(2) + \cdots + f(2^{32} - 1).
f
(
0
)
+
f
(
1
)
+
f
(
2
)
+
⋯
+
f
(
2
32
−
1
)
.
2019
team
function