AtCoder ABC 129F Takahashi's Basics in Education and Learning

Topic links: https://atcoder.jp/contests/abc129/tasks/abc129_f

Subject to the effect

  Given a length L, the first term is A, the number of arithmetic tolerance of column B S, L number of these pieces together, denoted as N, N% M. seek

analysis

  Setting bit (i) as a decimal displacement required to item i.
  则 $N = S_0 * 10^{bit(0)} + S_1 * 10^{bit(1)} + \dots + S_{L - 1} * 10^{bit(L - 1)}$。
  One by one be sure to overtime, but a less than notice arithmetic progression every 10 18  , the length of many items are equal, that there are many bit (i) is the arithmetic sequence.
  So we can follow the digits to the arithmetic sequence packets, divided into up to 18 groups.
  For example, in the interval [L, R], each have a length to be k.
  Denote the number of sections represented as A (k), A (k) for each set $ a_i, (L \ leq i \ leq R) $, the $ a_i = S_i * 10 ^ {bit (i )}, A (k) = \ sum_ {i = L} ^ {R} a_i $.

code show as below

Guess you like

Origin www.cnblogs.com/zaq19970105/p/11100184.html