#P6857. 梦中梦与不再有梦

梦中梦与不再有梦

Description

Amazing John wants to make a problem based on his dreams.

Amazing John had nn dreams. Between every pair of dreams, there is exactly one bridge directly connecting them, and no bridge connects a dream to itself.

By crossing a bridge eu,ve_{u,v}, you can go from dream uu to dream vv, or from vv to uu, and gain 11 rest point.

For every bridge eu,ve_{u,v}, it can only be crossed once, no matter whether you cross it forward or backward.

When you arrive at a dream and all bridges connected to it can no longer be crossed, Amazing John will stop dreaming.

Now Amazing John is very sleepy. He wants to know: starting from any dream, what is the maximum number of rest points he can obtain?

Input Format

This problem has multiple test cases.

The first line contains a positive integer TT, meaning there are TT test cases.

Next are TT lines. Each line contains a positive integer nn, meaning he had nn dreams.

Output Format

Output a total of TT lines.

For each test case, output one positive integer ansans, meaning the maximum rest points that can be obtained.

1
3
3

Hint

Sample explanation:

Start from 11, go along e1,2e_{1,2} to reach 22, then along e2,3e_{2,3} to reach 33, and finally along e3,1e_{3,1} to reach 11.

In total, you gain 33 rest points.

Subtask Test Points Constraints Score
11 121\sim2 n6,T=3n \le 6, T = 3 3030
22 353\sim5 n109,T105n \le 10^9, T \le 10^5 7070

For a subtask, you can get its score if and only if you pass all test points in that subtask.

Translated by ChatGPT 5