Codeforces Round 1061 (Div. 2)
A
Pizza Time
Codeforces
800
原题
←B →
翻译中…

Hao and Alex are good friends. After winning a coding competition together, they received a huge pizza as their prize.

翻译中…

Initially, they are given $n$ slices of pizza. Each day, the following process takes place:

翻译中…
  • If there are at most $2$ slices remaining, Alex eats all of them.
  • Otherwise, let $m$ be the current number of slices ($m\ge 3$). Hao splits them into three groups of sizes $m_1$, $m_2$, and $m_3$ such that:$$m_1 + m_2 + m_3 = m\text{ and } 1 \le m_1\le m_2\le m_3.$$Then:
  • Hao eats $m_1$ slices (the smallest group).
    • Alex eats $m_2$ slices (the middle group).
    • The remaining $m_3$ slices (the largest group) are carried over to the next day.
翻译中…

Your task is to determine the maximum total number of slices Hao can eat if he always chooses the partition optimally.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

The first and only line of each test case contains a single integer $n$ ($3 \le n \le 10^9$) — the initial number of pizza slices.

翻译中…

Note that there are no constraints on the sum of $n$ over all test cases.

翻译中…

Output

翻译中…

For each test case, output a single integer representing the maximum total number of slices Hao can eat.

翻译中…

Note

翻译中…

In the first test case, Hao can eat $3$ slices as follows:

翻译中…
  1. Split into $m_1 = 2$, $m_2 = 3$, and $m_3 = 3$. Hao eats $2$ slices, Alex eats $3$ slices, and the remaining $3$ slices are carried over to the next day.
  2. Split into $m_1 = 1$, $m_2 = 1$, and $m_3 = 1$. Hao eats $1$ slice, Alex eats $1$ slice, and the remaining $1$ slice is carried over to the next day.
  3. Only $1$ slice remains, so Alex eats it.
翻译中…

In the second test case, Hao can eat $1$ slice as follows:

翻译中…
  1. Split into $m_1 = 1$, $m_2 = 1$, and $m_3 = 2$. Hao eats $1$ slice, Alex eats $1$ slice, and the remaining $2$ slices are carried over to the next day.
  2. Only $2$ slices remain, so Alex eats them all.
翻译中…

样例

Input #1
3
8
4
3
Output #1
3
1
1
InputCopy OutputCopy
题目信息
题号
2156A
时间限制
1 s
内存限制
256 MB
标签
暴力
构造
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。