A polygon has 1325 diagonals. How many vertices does it have?
Answer
The formula to find number of diagonals (D) given total number of vertices or sides (N) is
N * (N - 3)
D = -----------
2
Using the formula, we get
1325 * 2 = N * (N - 3)
N2 - 3N - 2650 = 0
Solving the quadratic equation, we get N = 53 or -50
It is obvious that answer is 53 as number of vertices can not be negative.
Alternatively, you can derive the formula as triange has 0 diagonals, quadrangel has 2, pentagon has 5, hexagon has 9 and so on......
Hence the series is 0, 0, 0, 2, 5, 9, 14, ........ (as diagram with 1,2 or 3 vertices will have 0 diagonals).
Using the series one can arrive to the formula given above.
Consider the following example:
class B { ... };
class D : public B { ... };
void f()
{
B* pb = new D; // unclear but ok
B* pb2 = new B;
D* pd = dynamic_cast...
No comments:
Post a Comment