#P11955. Segment Tree Interval Cover
Segment Tree Interval Cover
Segment Tree Interval Cover
In this problem, Le Cheval loves the segment tree – his favorite data structure. For a positive integer (n), he builds a segment tree on the interval ([1,n]) as follows:
- The initial tree consists of a single node covering ([1,n]).
- For any node covering ([l,r]) with (l < r), let (mid = \lfloor (l+r)/2 \rfloor). Then two children are created: one covering ([l,mid]) and the other covering ([mid+1,r]).
For any sub‐interval ([l,r]) of ([1,n]), define its canonical cover (S_{[l,r]}) as the minimum set of pairwise disjoint tree nodes (from the segment tree constructed above) whose union is exactly ([l,r]). (This is exactly the set of nodes returned by a standard segment tree query on ([l,r]); note that if ([l,r]) exactly equals the range of some node then the cover is just that one node.)
Let (U) be the set of all nodes in the segment tree built on ([1,n]). We call a collection (T) of sub–intervals (each a sub–interval of ([1,n])) a cover if [ \bigcup_{[l,r] \in T} S_{[l,r]} = U. ] Denote by (f(n)) the minimum possible size of such a collection (T) (when (n=i), we write (f_i = |T|)).
Your task is: Given two integers (l) and (r) (with (1 \le l \le r)), compute [ \left( \sum_{i=l}^{r} f(i) \right) \bmod 353442899. ]
It is guaranteed that a valid collection exists for every (n\ge 1).
inputFormat
The input consists of a single line containing two integers (l) and (r) ((1 \le l \le r)).
outputFormat
Output a single integer – the value of (\Big( \sum_{i=l}^{r} f(i) \Big) \bmod 353442899).
sample
1 1
1
</p>