問題一覧 > 通常問題

No.831 City Tour

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 122
作問者 : Shuz* / テスター : tatyam
お気に入りにしたユーザー ProblemId : 2444 / 自分の提出
問題文最終更新日: 2019-05-24 23:48:28
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 214 (順位表) の他の問題:

Problem Statement

Fourier-kun is touring the cities of the country of Shuz.
The country of Shuz has $N$ cities, numbered $1,\ 2,\ 3,\ ...,\ N$.
Every pair of $2$ cities is connected by an expressway, and when $i \neq j$, traveling between cities $i,\ j$ costs a base fee of $(i \times j)$ yen one way.
In addition, when traveling from city $i$ to city $j$, an additional fee of $(j-i)$ yen is charged if $i \lt j$, and a discount of $(i-j)$ yen is applied if $i \gt j$.
That is, when $i \neq j$, traveling from city $i$ to city $j$ costs a total of $(i \times j)+(j-i)$ yen.
Fourier-kun wants to start from any city he likes and make a round trip through the cities of Shuz using the expressways.
Find the minimum fee required for Fourier-kun to visit all $N$ cities $1$ time each and return to the city where he started.

Constraints

  • $1 \le N \le 2 \times 10^6$
  • All inputs are integers

Input

The input is given from standard input in the following format.

$N$

Output

Output the minimum fee required for Fourier-kun to visit all the cities $1$ time each.

Sample

Sample 1
Input
3
Output
11

For example, one of the cheapest routes is as follows:
from city $2$ to city $1$: $1$ yen
from city $1$ to city $3$: $5$ yen
from city $3$ to city $2$: $5$ yen
The total is $11$ yen,
so output the total fee, $11$.

Sample 2
Input
1
Output
0

If there is only $1$ city, there is no need to tour the cities, so no fee is charged.

Sample 3
Input
200
Output
1353499

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