#P0287. Permutation Warm-Up
Permutation Warm-Up
题目描述
For a permutation of length , we define the function:
You are given a number . You need to compute how many distinct values the function can take when considering all possible permutations of the numbers from to .
A permutation of length is an array consisting of distinct integers from to in arbitrary order. For example, is a permutation, but is not a permutation ( appears twice in the array), and is also not a permutation ( but there is in the array).
输入格式
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains an integer () — the number of numbers in the permutations.
输出格式
For each test case, output a single integer — the number of distinct values of the function for the given length of permutations.
输入输出样例 #1
输入 #1
5
2
3
8
15
43
输出 #1
2
3
17
57
463
说明/提示
Consider the first two examples of the input.
For , there are only permutations — and . $ f([1, 2]) = \lvert 1 - 1 \rvert + \lvert 2 - 2 \rvert = 0 $, $ f([2, 1]) = \lvert 2 - 1 \rvert + \lvert 1 - 2 \rvert = 1 + 1 = 2 $. Thus, the function takes distinct values.
For , there are already permutations: , , , , , , the function values of which will be , and respectively, meaning there are a total of values.