Solomon Golomb's selfdescribing sequence
<!-- MATH: $\langle f(1), f(2), f(3), \dots \rangle$ -->
WIDTH="160" HEIGHT="34" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/754-1.gif"
ALT="$\langle f(1), f(2), f(3), \dots \rangle$">
is the only nondecreasing sequence of positive integers with the property
that it contains exactly f(k) occurrences of k for each k. A few moments
thought reveals that the sequence must begin as follows:
The input may contain multiple test cases. Each test case occupies a separate line
and contains an integer n
(
<!-- MATH: $1 \le n \le 2,000,000,000$ -->
WIDTH="181" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
SRC="/ntujudge/problemdata/754-3.gif"
ALT="$1 \le n \le 2,000,000,000$">). The input terminates with a test case
containing a value 0 for n and this case must not be processed.
For each test case in the input output the value of f(n) on a separate line.
100
9999
123456
1000000000
0
21
356
1684
438744
Migrated from old NTUJ.
UVA 10049
No. | Testdata Range | Score |
---|