QOJ.ac

QOJ

时间限制: 1 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#17932. Making Colorful Chocolates

统计

Coco wants to make a chocolate bar in the shape of a triangle, composed of regular hexagonal pieces. Since making it plain is boring, she wants to create a pattern by joining two types of chocolate as shown in the figure below. White represents white chocolate, and blue represents mint chocolate.

The specific method for creating this pattern is as follows:

  • The top vertex must have a mint chocolate.
  • From the position of every mint chocolate, there must also be a mint chocolate at every position reachable by the following move:
    • Move 1 unit in any direction where there is an adjacent chocolate, then turn 60 degrees to the left or right and move 1 more unit.

When the chocolates are numbered horizontally as shown in the figure, let's find the number of the $n$-th smallest mint chocolate.

Input

The first line contains the number of test cases $T$ ($1 \le T \le 10^5$).

Each of the following $T$ lines contains a single integer $n$ ($1 \le n \le 10^{16}$).

Output

For each test case, output the number of the $n$-th smallest mint chocolate on a single line.

Examples

Input 1

6
2
7
18
281
8284
59045

Output 1

5
20
52
841
24850
177133

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.