luogu#P2303. [SDOI2012] Longge 的问题

    ID: 1352 远端评测题 3000ms 125MiB 尝试: 1 已通过: 1 难度: 7 上传者: 标签>数学2012各省省选山东O2优化欧拉函数

[SDOI2012] Longge 的问题

Background

Longge excels at mathematics, and he enjoys tackling challenging math problems.

Problem Description

Here is the problem: Given an integer nn, you need to compute i=1ngcd(i,n)\sum\limits_{i=1}^n \gcd(i, n), where gcd(i,n)\gcd(i, n) denotes the greatest common divisor of ii and nn.

Input Format

The input consists of a single line containing the integer nn.

Output Format

Output a single integer on one line representing the answer.

6

15

Hint

Constraints

  • For 60%60\% of the testdata, it is guaranteed that n216n \leq 2^{16}.
  • For 100%100\% of the testdata, it is guaranteed that 1n<2321 \leq n < 2^{32}.

Translated by ChatGPT 5