AT_arc224_b.Adjacent Tiles

普及-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

Let us place NN square tiles of the same size on a plane so that they do not overlap.
Then, what is the maximum possible number of pairs of different tiles that share one full side?

Here, a pair of different tiles (a,b)(a,b) is said to share one full side if and only if some side of aa and some side of bb coincide completely.

TT test cases are given; solve each of them.

我们将在平面上放置 NN 个相同大小的正方形瓷砖,且它们互不重叠。
那么,恰好共享一条完整边的不同瓷砖对的最大可能数量是多少?

这里,不同瓷砖对 (a,b)(a,b) 被称为恰好共享一条完整边,当且仅当 aa 的某条边与 bb 的某条边完全重合。

共给出 TT 个测试用例;请逐一求解。

输入格式

The input is given from Standard Input in the following format, where casei\mathrm{case}_i denotes the ii-th test case:

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

Each test case is given in the following format:

NN

输入从标准输入给出,格式如下,其中 casei\mathrm{case}_i 表示第 ii 个测试用例:

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

每个测试用例的格式如下:

NN

输出格式

Output TT lines. The ii-th line should contain the answer for the ii-th test case.

输出 TT 行。第 ii 行应包含第 ii 个测试用例的答案。

输入输出样例

  • 输入#1

    6
    1
    2
    3
    4
    100000000000000000
    1000000000000000000

    输出#1

    0
    1
    2
    4
    199999999367544467
    1999999998000000000

说明/提示

Sample 1 Explanation:
This input contains six test cases.

The figure below shows an example of an optimal arrangement of tiles for N=1,2,3,4N=1,2,3,4.

  • For the first test case, N=1N=1.
    • There is no pair of different tiles sharing one full side.
  • For the second test case, N=2N=2.
    • The pair of tiles (a,b)({\rm a,b}) shares one full side.
  • For the third test case, N=3N=3.
    • The pairs of tiles (a,b),(b,c)({\rm a,b}),({\rm b,c}) share one full side.
  • For the fourth test case, N=4N=4.
    • The pairs of tiles (a,b),(a,c),(b,d),(c,d)({\rm a,b}),({\rm a,c}),({\rm b,d}),({\rm c,d}) share one full side.

Constraints

  • 1≤T≤2×1051 \le T \le 2 \times 10^5
  • 1≤N≤10181 \le N \le 10^{18}
  • All input values are integers.

样例 1 解释:
该输入包含六个测试用例。

下图展示了 N=1,2,3,4N=1,2,3,4 时瓷砖的最优排列示例。

  • 对于第一个测试用例,N=1N=1。
    • 不存在任意两个不同的瓷砖共享一条完整边。
  • 对于第二个测试用例,N=2N=2。
    • 瓷砖对 (a,b)({\rm a,b}) 共享一条完整边。
  • 对于第三个测试用例,N=3N=3。
    • 瓷砖对 (a,b),(b,c)({\rm a,b}),({\rm b,c}) 各自共享一条完整边。
  • 对于第四个测试用例,N=4N=4。
    • 瓷砖对 (a,b),(a,c),(b,d),(c,d)({\rm a,b}),({\rm a,c}),({\rm b,d}),({\rm c,d}) 各自共享一条完整边。

约束条件

  • 1≤T≤2×1051 \le T \le 2 \times 10^5
  • 1≤N≤10181 \le N \le 10^{18}
  • 所有输入值均为整数。

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

首页