A11010 | Level Generation
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $n_{i}$ vertices in the graph representing level $i$ , and the edges have to be bidirectional. When constructing the graph, Ivan is interested in special edges called bridges. An edge between two vertices $u$ and $v$ is called a bridge if this edge belongs to every path between $u$ and $v$ (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 $q$ numbers $n_{1},n_{2},...,n_{q}$ , for each $i$ tell the maximum number of edges in a graph with $n_{i}$ vertices, if at least half of the edges are bridges. Note that the graphs cannot contain multiple edges or self-loops.
Ivan decided that there should be exactly $n_{i}$ vertices in the graph representing level $i$ , and the edges have to be bidirectional. When constructing the graph, Ivan is interested in special edges called bridges. An edge between two vertices $u$ and $v$ is called a bridge if this edge belongs to every path between $u$ and $v$ (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 $q$ numbers $n_{1},n_{2},...,n_{q}$ , for each $i$ tell the maximum number of edges in a graph with $n_{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 $q$ ( $1<=q<=100000$ ) — the number of graphs Ivan needs to construct.
Then $q$ lines follow, $i$ -th line contains one positive integer $n_{i}$ ( $1<=n_{i}<=2·10^{9}$ ) — the number of vertices in $i$ -th graph.
Note that in hacks you have to use $q=1$ .
Then $q$ lines follow, $i$ -th line contains one positive integer $n_{i}$ ( $1<=n_{i}<=2·10^{9}$ ) — the number of vertices in $i$ -th graph.
Note that in hacks you have to use $q=1$ .
输出格式
Output $q$ numbers, $i$ -th of them must be equal to the maximum number of edges in $i$ -th graph.
输入输出样例
输入 #1
3 3 4 6
输出 #1
2 3 6
In the first example it is possible to construct these graphs:
1. $1-2$ , $1-3$ ;
2. $1-2$ , $1-3$ , $2-4$ ;
3. $1-2$ , $1-3$ , $2-3$ , $1-4$ , $2-5$ , $3-6$ .
1. $1-2$ , $1-3$ ;
2. $1-2$ , $1-3$ , $2-4$ ;
3. $1-2$ , $1-3$ , $2-3$ , $1-4$ , $2-5$ , $3-6$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted