A circle is given with k equidistant points on its circumference. 2 points A and B are given in the circle. Find the count of all obtuse angles (angles larger than 90 degree) formed from /_ACB, where C can be any point in circle other than A or B.

Note :

A and B are not equal.

A < B.

Points are between 1 and K(both inclusive).

Examples :

Input : K = 6, A = 1, B = 3. Output : 1 Explanation : In the circle with 6 equidistant points, when C = 2 i.e. /_123, we get obtuse angle. Input : K = 6, A = 1, B = 4. Output : 0 Explanation : In this circle, there is no such C that form an obtuse angle.

It can be observed that if A and B have equal elements in between them, there can’t be any C such that ACB is obtuse. Also, the number of possible obtuse angles are the smaller arc between A and B.

Below is the implementation :

`// C++ program to count number of obtuse ` `// angles for given two points. ` `#include <bits/stdc++.h> ` `using` `namespace` `std; `
` ` `int` `countObtuseAngles(` `int` `a, ` `int` `b, ` `int` `k) `
`{ ` ` ` `// There are two arcs connecting a `
` ` `// and b. Let us count points on `
` ` `// both arcs. `
` ` `int` `c1 = (b - a) - 1; `
` ` `int` `c2 = (k - b) + (a - 1); `
` ` ` ` `// Both arcs have same number of `
` ` `// points `
` ` `if` `(c1 == c2) `
` ` `return` `0; `
` ` ` ` `// Points on smaller arc is answer `
` ` `return` `min(c1, c2); `
`} ` ` ` `// Driver code ` `int` `main() `
`{ ` ` ` `int` `k = 6, a = 1, b = 3; `
` ` `cout << countObtuseAngles(a, b, k); `
` ` `return` `0; `
`} ` |

*chevron_right*

*filter_none*

`// Java program to count number of obtuse ` `// angles for given two points ` `class` `GFG { `
` ` ` ` `static` `int` `countObtuseAngles(` `int` `a, `
` ` `int` `b, ` `int` `k) `
` ` `{ `
` ` ` ` `// There are two arcs connecting a `
` ` `// and b. Let us count points on `
` ` `// both arcs. `
` ` `int` `c1 = (b - a) - ` `1` `; `
` ` `int` `c2 = (k - b) + (a - ` `1` `); `
` ` ` ` `// Both arcs have same number of `
` ` `// points `
` ` `if` `(c1 == c2) `
` ` `return` `0` `; `
` ` ` ` `// Points on smaller arc is answer `
` ` `return` `min(c1, c2); `
` ` `} `
` ` ` ` `// Driver Program to test above function `
` ` `public` `static` `void` `main(String arg[]) `
` ` `{ `
` ` ` ` `int` `k = ` `6` `, a = ` `1` `, b = ` `3` `; `
` ` `System.out.print(countObtuseAngles(a, b, k)); `
` ` `} `
`} ` ` ` `// This code is contributed by Anant Agarwal. ` |

*chevron_right*

*filter_none*

`# C++ program to count number of obtuse ` `# angles for given two points. ` ` ` `def` `countObtuseAngles( a, b, k): `
` ` `# There are two arcs connecting a `
` ` `# and b. Let us count points on `
` ` `# both arcs. `
` ` `c1 ` `=` `(b ` `-` `a) ` `-` `1`
` ` `c2 ` `=` `(k ` `-` `b) ` `+` `(a ` `-` `1` `) `
` ` ` ` `# Both arcs have same number of `
` ` `# points `
` ` `if` `(c1 ` `=` `=` `c2): `
` ` `return` `0`
` ` ` ` `# Points on smaller arc is answer `
` ` `return` `min` `(c1, c2) `
` ` `# Driver code ` `k, a, b ` `=` `6` `, ` `1` `, ` `3`
`print` `countObtuseAngles(a, b, k) `
` ` `# This code is contributed by Sachin Bisht ` |

*chevron_right*

*filter_none*

`// C# program to count number of obtuse ` `// angles for given two points ` `using` `System; `
` ` `class` `GFG { `
` ` ` ` `static` `int` `countObtuseAngles(` `int` `a, `
` ` `int` `b, ` `int` `k) `
` ` `{ `
` ` ` ` `// There are two arcs connecting `
` ` `// a and b. Let us count points `
` ` `// on both arcs. `
` ` `int` `c1 = (b - a) - 1; `
` ` `int` `c2 = (k - b) + (a - 1); `
` ` ` ` `// Both arcs have same number `
` ` `// of points `
` ` `if` `(c1 == c2) `
` ` `return` `0; `
` ` ` ` `// Points on smaller arc is `
` ` `// answer `
` ` `return` `Math.Min(c1, c2); `
` ` `} `
` ` ` ` `// Driver Program to test above `
` ` `// function `
` ` `public` `static` `void` `Main() `
` ` `{ `
` ` ` ` `int` `k = 6, a = 1, b = 3; `
` ` ` ` `Console.WriteLine( `
` ` `countObtuseAngles(a, b, k)); `
` ` `} `
`} ` ` ` `// This code is contributed by vt_m. ` |

*chevron_right*

*filter_none*

`<?php ` `// PHP program to count number ` `// of obtuse angles for given ` `// two points. ` ` ` `function` `countObtuseAngles(` `$a` `, ` `$b` `, ` `$k` `) `
`{ ` ` ` `// There are two arcs connecting a `
` ` `// and b. Let us count points on `
` ` `// both arcs. `
` ` `$c1` `= (` `$b` `- ` `$a` `) - 1; `
` ` `$c2` `= (` `$k` `- ` `$b` `) + (` `$a` `- 1); `
` ` ` ` `// Both arcs have same number of `
` ` `// points `
` ` `if` `(` `$c1` `== ` `$c2` `) `
` ` `return` `0; `
` ` ` ` `// Points on smaller arc is answer `
` ` `return` `min(` `$c1` `, ` `$c2` `); `
`} ` ` ` `// Driver code ` `$k` `= 6; ` `$a` `= 1; ` `$b` `= 3; `
`echo` `countObtuseAngles(` `$a` `, ` `$b` `, ` `$k` `); `
` ` `// This code is contributed by aj_36 ` `?> ` |

*chevron_right*

*filter_none*

**Output :**

1

This article is contributed by **Rohit Thapliyal**. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Count of acute, obtuse and right triangles with given sides
- Total number of triplets (A, B, C) in which the points B and C are Equidistant to A
- Program to find smallest difference of angles of two parts of a given circle
- Equation of circle when three points on the circle are given
- Check whether it is possible to join two points given on circle such that distance between them is k
- Angle subtended by the chord to center of the circle when the angle subtended by the another equal chord of a congruent circle is given
- Find area of the larger circle when radius of the smaller circle and difference in the area is given
- Find all angles of a given triangle
- Check whether the triangle is valid or not if angles are given
- Check whether Quadrilateral is valid or not if angles are given
- Length of remaining two sides of a Triangle from a given side and its adjacent angles
- Check if an N-sided Polygon is possible from N given angles
- Queries on count of points lie inside a circle
- Program to calculate area of inner circle which passes through center of outer circle and touches its circumference
- Check if a circle lies inside another circle or not
- Area of the circle that has a square and a circle inscribed in it
- Angular Sweep (Maximum points that can be enclosed in a circle of given radius)
- Find all angles of a triangle in 3D
- Program to find the angles of a quadrilateral
- Sum of internal angles of a Polygon

**Practice Tags :**