#P7122. Chino 与线段树

    ID: 6351 远端评测题 2000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>高精度2020O2优化快速傅里叶变换 FFT快速数论变换 NTT

Chino 与线段树

Problem Description

Chino has just learned a data structure called the segment tree. However, she ran into a problem when writing a segment tree: she does not know how much space to allocate. She only knows that the number of leaf nodes nn is a positive integer within the range [a,b][a,b].

Chino defines f(n)f(n) as the maximum array index used by a segment tree with nn leaf nodes. She believes that if she knows

n=abf(n)\sum_{n=a}^{b}f(n)

then she can figure out how much space she needs. So she asks you, the clever one, to help her.

Specifically, the pseudocode for building the segment tree is as follows:

$\begin{aligned} &\underline{\kern{300pt}}\\ &\mathbf{Function:}\ \text{Build a Segment Tree.}\\[-10pt] &\underline{\kern{300pt}}\\[-5pt] &\begin{array}{r|l} 1&\ \mathbf{function}\ \text{BuildSegmentTree}(x,l,r):\\ 2&\qquad \mathbf{if}\ (l \ne r)\ \mathbf{then}:\\ 3&\qquad\qquad m \gets \left\lfloor (l+r)/2 \right\rfloor\\ 4&\qquad\qquad \text{BuildSegmentTree}(2x,l,m)\\ 5&\qquad\qquad \text{BuildSegmentTree}(2x+1,m+1,r)\\ 6&\qquad \mathbf{end\ if}\\ 7&\ \mathbf{end\ function}\\ \end{array}\\[-13pt] &\underline{\kern{300pt}} \end{aligned}$

The maximum array index used by the segment tree is the maximum value of the parameter xx among all calls to BuildSegmentTree\def\t#1{\text{#1}}\t{BuildSegmentTree} after executing $\def\t#1{\text{#1}}\t{BuildSegmentTree}\left(1,1,n\right)$.

Input Format

The input has two lines.

The first line contains a positive integer aa; the second line contains a positive integer bb. Their meanings are as described in the statement.

Output Format

Output one line containing one positive integer, which is your answer.

1
10

108

233333
666666

588544964910

1
1000000000000000000

1419691012023749904603586777179575510

Hint

Sample Explanation #1

For segment trees with 1101\sim 10 leaf nodes, the maximum indices are 1,3,5,7,9,13,13,15,17,251,3,5,7,9,13,13,15,17,25, respectively. Summing them gives 108108.

Test Point Constraints

This problem uses bundled testdata.

For all data, 1ab101061\le a\le b\le10^{10^6}.

The specific limits for each subtask are shown in the table below:

Subtask ID Score bb\le a=ba=b
1 10 1010010^{10^0} ×\times
2 1010110^{10^1}
3 1010210^{10^2}
4 1010310^{10^3} \surd
5 ×\times
6 1010410^{10^4} \surd
7 ×\times
8 1010510^{10^5} \surd
9 ×\times
10 1010610^{10^6}

Translated by ChatGPT 5