---
# System prepended metadata

title: AtCoder Beginner Contest 230 E(數論分塊)
tags: [' 數論', 題解]

---

---
title: "AtCoder Beginner Contest 230 E(數論分塊)"
tags: 題解, 數論
---

https://atcoder.jp/contests/abc230/tasks/abc230_e

#### 題意

求 $i = 1$ 到 $N$，$floor(N / i)$ 的和。

#### 思路

數論分塊的裸題。

#### Code

```python=1
def solve():
    N = int(input())

    ans = 0
    l = r = 1
    while l <= N:
        r = N // (N // l)
        ans += (r - l + 1) * (N // l)
        l = r + 1
    print(ans)

if __name__ == "__main__":
    solve()
```