#P10532. [XJTUPC 2024] 筛法

    ID: 11980 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>2024O2优化高校校赛

[XJTUPC 2024] 筛法

Problem Description

In number theory for algorithm competitions, we have encountered algorithms such as the Sieve of Eratosthenes, the linear sieve, Möbius inversion, the Du Jiao sieve, the Powerful Number sieve, the Min_25 sieve, and the Zhou Ge sieve to help optimize the complexity of some summations or products. Now here comes the question: which of the above algorithms will be used in today’s problem?

Given a positive integer nn, you need to compute

$$\sum\limits_{i=1}^n\sum\limits_{j=1}^n\lfloor \dfrac{n}{\max(i,j)}\rfloor [i \perp j]$$

where [ij][i \perp j] indicates whether ii and jj are coprime. That is, when gcd(i,j)=1\gcd(i,j)=1, the value of [ij][i \perp j] is 11; otherwise, its value is 00.

Input Format

One line contains a positive integer nn (1n1091\le n \le 10^9).

Output Format

Output one line containing an integer, representing the result of the above summation.

2
4

Hint

Translated by ChatGPT 5