C. Board Moves

You are given a board of size n×nn×n, where nn is odd (not divisible by 22). Initially, each cell of the board contains one figure.

In one move, you can select exactly one figure presented in some cell and move it to one of the cells sharing a side or a corner with the current cell, i.e. from the cell (i,j)(i,j) you can move the figure to cells:

  • (i1,j1)(i−1,j−1);
  • (i1,j)(i−1,j);
  • (i1,j+1)(i−1,j+1);
  • (i,j1)(i,j−1);
  • (i,j+1)(i,j+1);
  • (i+1,j1)(i+1,j−1);
  • (i+1,j)(i+1,j);
  • (i+1,j+1)(i+1,j+1);

Of course, you can not move figures to cells out of the board. It is allowed that after a move there will be several figures in one cell.

Your task is to find the minimum number of moves needed to get all the figures into one cell (i.e. n21n2−1 cells should contain 00 figures and one cell should contain n2n2 figures).

You have to answer tt independent test cases.

Input

The first line of the input contains one integer tt (1t2001≤t≤200) — the number of test cases. Then tt test cases follow.

The only line of the test case contains one integer nn (1n<51051≤n<5⋅105) — the size of the board. It is guaranteed that nn is odd (not divisible by 22).

It is guaranteed that the sum of nn over all test cases does not exceed 51055⋅105 (n5105∑n≤5⋅105).

Output

For each test case print the answer — the minimum number of moves needed to get all the figures into one cell.

思路:在中点处,向外每一层需要的步数加一,步数乘这一乘的方块数

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll ans = 0;
        n /= 2;
        for (ll i = 1; i <= n; i++)
        {
            ans += i * 8 * i;
        }
        cout << ans << endl;
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/yin101/p/12897198.html