#B4134. Toggle Lights Sum Problem

    ID: 11791 Type: Default 1000ms 256MiB

Toggle Lights Sum Problem

Toggle Lights Sum Problem

There are n lights labeled from 1 to n and n people. All lights are initially off. The people operate on the lights sequentially as follows:

  • The 1st person turns all the lights on.
  • The 2nd person toggles the state (on becomes off, off becomes on) of every light whose number is a multiple of 2.
  • The 3rd person toggles every light whose number is a multiple of 3.
  • And so on, until the ith person toggles every light whose number is a multiple of i (for 1 ≤ in).

After all operations, compute the sum of the indices of all lights that remain on.

Hint: A light ends up on if and only if it is toggled an odd number of times. This happens exactly when the light's index is a perfect square. Therefore, the answer can be computed as:

\[ \text{Answer} = \sum_{i=1}^{\lfloor \sqrt{n} \rfloor} i^2 \]

inputFormat

The input consists of a single integer n (1 ≤ n ≤ 1012), representing the number of lights (and people).

outputFormat

Output a single integer denoting the sum of the indices of the lights that are on after all operations.

sample

1
1