QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#17932. 알록달록 초콜릿 만들기

统计

Coco 想要制作一个由正六边形巧克力拼接成三角形形状的巧克力。为了让制作过程更有趣,她决定像下图一样,用两种巧克力拼接出一种图案。白色的是白巧克力,蓝色的是薄荷巧克力。

制作这种图案的具体方法如下:

  • 最顶端的顶点处必须放置薄荷巧克力。
  • 从任意一个薄荷巧克力所在的位置出发,按照以下方式可以到达的所有位置也必须放置薄荷巧克力:
    • 向有相邻巧克力的任意方向移动 1 格,然后向左或向右旋转 60 度再移动 1 格。

如果像图中那样按横向顺序进行编号,求编号第 $n$ 小的薄荷巧克力的编号。

输入格式

第一行包含测试用例的数量 $T$($1 \le T \le 10^5$)。

接下来的 $T$ 行,每行包含一个整数 $n$($1 \le n \le 10^{16}$)。

输出格式

对于每个测试用例,在一行中输出编号第 $n$ 小的薄荷巧克力的编号。

样例

输入样例 1

6
2
7
18
281
8284
59045

输出样例 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.