問題一覧 > 通常問題

No.2249 GCDistance

レベル : / AI推定難易度 : 1200 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 122
作問者 : bayashiko / テスター : kumakuma 👑 AngrySadEight
お気に入りにしたユーザー ProblemId : 9320 / 自分の提出
問題文最終更新日: 2023-03-13 14:32:41
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 381 (順位表) の他の問題:

Problem Statement

There is a weighted undirected complete graph $G$ with $N$ vertices, and the vertices of $G$ are numbered from $1$ to $N$.

The weight of the edge connecting vertex $i$ and vertex $j(i < j)$ of $G$ is $\gcd(i,j)$, that is, the greatest common divisor of $i$ and $j$.

Let $dist(x,y)$ be the minimum total weight of the edges traversed when moving from vertex $x$ to vertex $y$ by following some edges.

Find $\sum_{i=1}^{N-1}\sum_{j=i+1}^{N} dist(i,j)$. It is guaranteed that the answer is less than $2^{63}$ under the given constraints.

For $1$ input file, answer $T$ test cases.

Input

$T$
$case_1$
$case_2$
:
$case_T$
Each test case is given in the following format.
$N$

  • $1\le T \le 2×10^5$
  • $2\le N\le 10^7$
  • All inputs are integers.

Output

Output the answers. On line $i$, output the answer to test case $i$.

Sample

Sample 1
Input
3
2
4
10000000
Output
1
7
69603633572759

When $N=2$, $dist(1,2)=1$, so the answer to test case $1$ is $1$.

When $N=4$, $dist(1,2)=1,dist(1,3)=1,dist(1,4)=1,dist(2,3)=1,dist(2,4)=2,dist(3,4)=1$, so the answer to test case $2$ is $1+1+1+1+2+1=7$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。