#P8618. [蓝桥杯 2014 国 B] Log 大侠
[蓝桥杯 2014 国 B] Log 大侠
Description
atm joined a mental arithmetic training class. After hard practice, he became very fast at computing logarithms base , and is known as the Log Hero.
One day, the Log Hero’s friend drd has some integer sequences to transform, and the Log Hero happens to use his power.
The transformation rule is: for every integer in some chosen subarray, change it to , where means taking the floor. That is, for each number, compute the base logarithm and then take the floor.
For example, applying the operation once to the sequence will change it into .
drd needs to know, after each such operation, what the sum of the entire sequence is.
Input Format
The first line contains two positive integers .
The second line contains numbers, representing the integer sequence, all of which are positive.
The next lines each contain two numbers and , meaning that in this operation atm applies the transformation to the interval . The sequence is indexed starting from .
Output Format
Output lines. Each line should be the sum of the entire sequence after atm finishes one operation, in order.
3 3
5 6 4
1 2
2 3
1 3
10
8
6
Hint
For of the testdata, .
For of the testdata, .
Time limit: 1 second, 256M. Lanqiao Cup 2014, the 5th National Final.
The official testdata seems to be wrong. The rebuilt testdata is designed with .
Translated by ChatGPT 5
京公网安备 11011102002149号