CF818F.Level Generation

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Ivan is developing his own computer game. Now he tries to create some levels for his game. But firstly for each level he needs to draw a graph representing the structure of the level.

Ivan decided that there should be exactly nin_{i} vertices in the graph representing level ii , and the edges have to be bidirectional. When constructing the graph, Ivan is interested in special edges called bridges. An edge between two vertices uu and vv is called a bridge if this edge belongs to every path between uu and vv (and these vertices will belong to different connected components if we delete this edge). For each level Ivan wants to construct a graph where at least half of the edges are bridges. He also wants to maximize the number of edges in each constructed graph.

So the task Ivan gave you is: given qq numbers n1,n2,...,nqn_{1},n_{2},...,n_{q} , for each ii tell the maximum number of edges in a graph with nin_{i} vertices, if at least half of the edges are bridges. Note that the graphs cannot contain multiple edges or self-loops.

输入格式

The first line of input file contains a positive integer qq ( 1<=q<=1000001<=q<=100000 ) — the number of graphs Ivan needs to construct.

Then qq lines follow, ii -th line contains one positive integer nin_{i} ( 1<=ni<=21091<=n_{i}<=2·10^{9} ) — the number of vertices in ii -th graph.

Note that in hacks you have to use q=1q=1 .

输出格式

Output qq numbers, ii -th of them must be equal to the maximum number of edges in ii -th graph.

输入输出样例

  • 输入#1

    3
    3
    4
    6
    

    输出#1

    2
    3
    6
    

说明/提示

In the first example it is possible to construct these graphs:

  1. 121-2 , 131-3 ;
  2. 121-2 , 131-3 , 242-4 ;
  3. 121-2 , 131-3 , 232-3 , 141-4 , 252-5 , 363-6 .
首页