E - Jilila

Time limit: 0.25s Memory limit: 64MB Input: Output:

Cerință

Se dă un șir aa de NN elemente.

Se defintește:
f(x)={1daca˘ x=11+f(x)daca˘ x>1f(x) = \begin{cases} 1 &\text{dacă } x = 1 \\ 1 + f(\lfloor \sqrt{x} \rfloor) &\text{dacă } x > 1 \end{cases}

Să se calculeze: i=1Nj=iNf(k=ijak)\sum_{i=1}^N \sum_{j=i}^N f(\sum_{k=i}^j a_k).

Date de intrare

Pe prima linie se află NN, iar pe a doua linie șirul aa.

Date de ieșire

Se va afișa suma cerută.

Restricții și precizări

  • 1N,ai21061 \leq N, a_i \leq 2 \cdot 10^6
  • Pentru 7070 de puncte 1N,ai21051 \leq N, a_i \leq 2 \cdot 10^5
  • Se recomandă folosirea următoarei secvențe de cod pentru o citire rapidă:
ios_base::sync_with_stdio(false);
cin.tie(0);

Exemplul 1

stdin

2
1 3

stdout

6

Exemplul 2

stdin

8
123 423 12 48 1 2 3 99999

stdout

160

Log in or sign up to be able to send submissions!