CF1670D.Very Suspicious

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam.

They love equilateral triangles and want to create nn equilateral triangles on the grid by adding some straight lines. The triangles must all be empty from the inside (in other words, no straight line or hexagon edge should pass through any of the triangles).

You are allowed to add straight lines parallel to the edges of the hexagons. Given nn, what is the minimum number of lines you need to add to create at least nn equilateral triangles as described?

Adding two red lines results in two new yellow equilateral triangles.

“非常可疑”(Sehr Sus)是一个如下图所示的无限六边形网格,由 MennaFadali、ZerooCool 和 Hosssam 控制。

他们热爱等边三角形,并希望在该网格上通过添加若干条直线来构造 nn 个等边三角形。这些三角形内部必须是空的(即:没有任何直线或六边形的边穿过任一三角形的内部)。

你只允许添加与六边形各边平行的直线。给定 nn,为构造至少 nn 个满足上述条件的等边三角形,你需要添加的直线的最少数量是多少?

添加两条红色直线后,可得到两个新的黄色等边三角形。

输入格式

The first line contains a single integer tt (1≤t≤1051 \le t \le 10^5) — the number of test cases. Then tt test cases follow.

Each test case contains a single integer nn (1≤n≤1091 \le n \le 10^{9}) — the required number of equilateral triangles.

第一行包含一个整数 tt(1≤t≤1051 \le t \le 10^5)—— 测试用例的数量。接下来是 tt 个测试用例。

每个测试用例包含一个整数 nn(1≤n≤1091 \le n \le 10^{9})—— 所需的等边三角形数量。

输出格式

For each test case, print the minimum number of lines needed to have nn or more equilateral triangles.

对于每个测试用例,输出得到 nn 个或更多等边三角形所需的最少直线数量。

输入输出样例

  • 输入#1

    4
    1
    2
    3
    4567

    输出#1

    2
    2
    3
    83

说明/提示

In the first and second test cases only 2 lines are needed. After adding the first line, no equilateral triangles will be created no matter where it is added. But after adding the second line, two more triangles will be created at once.

In the third test case, the minimum needed is 3 lines as shown below.

在第一和第二个测试用例中,仅需添加 2 条线段。添加第一条线段后,无论将其置于何处,都不会形成任何等边三角形;但添加第二条线段后,将同时生成两个新的等边三角形。

在第三个测试用例中,最少需要添加 3 条线段,如下图所示。

输入解题思路,AI测评打分。不知道怎么写?

首页