Problem Statement | |||||||||||||
In the Kocurkovo village there is a shop that sells simple planar graphs. (See Notes for a definition.) The cost of any graph with X vertices and Y edges is (X^3 + Y^2) gold coins. Monika has N gold coins, and she wants to spend all of them on simple planar graphs. Write a method that gets the value N and computes the minimum number of simple planar graphs Monika has to buy in order to spend exactly N gold coins. She is allowed to buy multiple graphs of the same type. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | A simple graph is an ordered pair (V,E) where V is a finite non-empty set of objects called vertices, and E is a finite set of edges. Each edge is a two-element subset of V. (You can find drawings of several graphs in Example #3.) | ||||||||||||
- | Note that a simple graph does not contain any loops (edges that connect a vertex to itself) and any duplicate edges. In other words, each edge connects two different vertices, and each pair of vertices is connected by at most one edge. | ||||||||||||
- | A graph is called planar if it has a drawing in the plane such that no two edges intersect. | ||||||||||||
- | Note that a simple planar graph does not have to be connected. | ||||||||||||
Constraints | |||||||||||||
- | N will be between 1 and 50,000, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|