#P8676. [蓝桥杯 2018 国 A] 自描述序列

[蓝桥杯 2018 国 A] 自描述序列

Description

Xiaoming is studying a sequence called the Golomb self-describing sequence, denoted as G(n)G(n). This sequence has two interesting properties:

  1. For any positive integer nn, nn appears in the whole sequence exactly G(n)G(n) times.

  2. This sequence is non-decreasing.

The following are the first few terms of G(n)G(n):

nn 1 2 3 4 5 6 7 8 9 10 11 12 13
G(n)G(n) 1 2 3 4 5 6

Given an integer nn, can you help Xiaoming compute the value of G(n)G(n)?

Input Format

An integer nn.

Output Format

Output one integer, which is the answer.

13
6

Hint

For 30%30\% of the testdata, 1n1061 \le n \le 10^6.

For 70%70\% of the testdata, 1n1091 \le n \le 10^9.

For 100%100\% of the testdata, 1n2×10151 \le n \le 2\times 10^{15}.

Time limit: 1 second, 256 MB. Lanqiao Cup 2018, the 9th National Finals.

Translated by ChatGPT 5