Wesley is taking a course on the network simplex algorithm. Unfortunately, a term that comes up often in class is simple graph. When the professor asked him what the minimum number of vertices a simple, undirected graph with
A graph is simple if it contains no self loops (an edge from a vertex to itself) and no multiple edges between any two vertices. Note that an edge between vertices
Since solving this problem once is easy, you will be asked to solve it
Constraints
For this problem, you will be required to pass all the samples in order to receive any points. In addition, you must pass all previous subtasks to earn points for a specific subtask.
Subtask | Points | |
---|---|---|
Input Specification
There will be multiple test cases.
The first line contains a single integer
Each test case consists of a single integer
Note that a 64-bit integer may need to be used to store long long
. In Java, this can be done with long
. In Python, the standard int
will suffice.
Output Specification
This problem is graded with an identical
checker. This includes whitespace characters. Ensure that every line of output is terminated with a \n
character and that there are no trailing spaces.
For each test case, output a single integer on its own line, the minimum number of vertices a simple, undirected graph with
Sample Input
2
1
4
Sample Output
2
4
Sample Explanation
One possible graph for the first test case is shown below.
One possible graph for the second test case is shown below.
Comments
Did you figure out how to fix it? I am having the same problem
I don't understand how
print(int(math.ceil((1+(math.sqrt(1+8*x)))/2)))
is wrong. I keep on getting WA for Batch 4 Case 5.there's some rounding inaccuracies,
found that out the hard way XD (sorry)try finding a way around using decimals