問題一覧 > 通常問題

No.1824 Kado\Matsu\Sequence

レベル : / AI推定難易度 : 1050 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 148
作問者 : mai / テスター : mine691
お気に入りにしたユーザー ProblemId : 6714 / 自分の提出
問題文最終更新日: 2022-04-26 21:28:46
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 329 (順位表) の他の問題:

Definition

It is said that a sequence of three elements $v = (a_1,a_2,a_3)$ is a Kadomatsu sequence when $v$ satisfies the following conditions.

  1. $a_1,a_2,a_3$ are all distinct
  2. Among the three elements, $a_2$ is the largest or the smallest

Problem Statement

You are given a sequence $A = (N,N-1,\ldots,2,1,N,N-1,\ldots,2,1)$ of length $2N$.
Output the number of tuples $(i, j, k)$ (where $i < j < k$) such that $(A_i, A_j, A_k)$ is a Kadomatsu sequence.

Input

$T$ test cases are given at once. ($1 \le T \le 10^4$)

$T$
$\text{TestCase}_1$
$\vdots$
$\text{TestCase}_T$

Each test case is given in the following format.

$N$
  • $3 \le N \le 10^6$

Output

For each test case, output the answer, separated by newlines.

Sample

Sample 1
Input
7
3
4
5
6
99
501
998244
Output
4
16
40
80
627396
83333000
663158837148037776

Among the subsequences of length 3 contained in 3,2,1,3,2,1, the following 4 are Kadomatsu sequences.

  • 3 1 2
  • 2 1 3
  • 2 3 1
  • 1 3 2

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