- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures

- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces

# Count of obtuse angles in a circle with â€˜k' equidistant points between 2 given points in C++

We are given a circle with K equidistant points on its circumference. Also we are given two points A and B. The goal is to count the number of triangles possible using these points such that they have an obtuse angle ACB( angle greater than 90o) inside them. The points A and B are such that A < B.

Here K=8, A=2, B=5, count of points=2 (C,C’) such that angle LACB, LAC’B are obtuse.

Let us understand with examples

**Input** − k=10, A=2, B=4

**Output** − Count of obtuse angles in a circle with ‘k' equidistant points between 2 given points are − 1

**Explanation** − The point will be C=3

**Input** − k=12, A=2, B=10

**Output** − Count of obtuse angles in a circle with ‘k' equidistant points between 2 given points are − 3

## Approach used in the below program is as follows

It can be seen that if the smaller the arc between A and B the points will lie on that arc only.

Calculate both arcs and if they are of equal length then no such triangle possible, return 0. Else set count as smaller arc which is distance in terms of points.

Take input as integers k, point_a and point_b.

Function Obtuse_angle_circle(int point_a, int point_b, int k) takes all variables and returns count of obtuse angles in a circle with ‘k' equidistant points between 2 given points

Take the initial count as 0.

Calculate the first arc as arc_1 = (point_b - point_a) - 1. (b>a)

Calculate the second arc as (k - point_b) + (point_a - 1).

If both arcs are equal then return 0 as no such points possible.

If they are unequal then update count as minimum of two as all points lie on it.

Return count as result.

## Example

#include <bits/stdc++.h> using namespace std; int Obtuse_angle_circle(int point_a, int point_b, int k){ int count = 0; int arc_1 = (point_b - point_a) - 1; int arc_2 = (k - point_b) + (point_a - 1); if (arc_1 == arc_2){ return 0; } count = min(arc_1, arc_2); return count; } int main(){ int k = 10; int point_a= 1; int point_b = 4; cout<<"Count of obtuse angles in a circle with ‘k' equidistant points between 2 given pointsare: "<<Obtuse_angle_circle(point_a, point_b, k); return 0; }

## Output

If we run the above code it will generate the following output −

Count of obtuse angles in a circle with ‘k' equidistant points between 2 given points are: 2

- Related Articles
- Queries on count of points lie inside a circle in C++
- If the point $P (k â€“ 1, 2)$ is equidistant from the points $A (3, k)$ and $B (k, 5)$, find the values of $k$.
- If the point $P (2, 2)$ is equidistant from the points $A (-2, k)$ and $B (-2k, -3)$, find $k$. Also, find the length of AP.
- Fill in the blanks:All points lying inside / outside a circle are called â€¦â€¦.. points / â€¦â€¦â€¦. points.
- Find the points on the \( y \)-axis which is equidistant from the points \( (-5,-2) \) and \( (3,2) \).
- Count triplet pairs (A, B, C) of points in 2-D space that satisfy the given condition in C++
- Number of Integral Points between Two Points in C++
- Prove that the tangents drawn at the end points of a chord of a circle make equal angles with the chord.
- Program to sort given set of Cartesian points based on polar angles in Python
- Count of triangles with total n points with m collinear in C++
- Find a point on y-axis which is equidistant from the points $(5, -2)$ and $(-3, 2)$.
- Coordinates of rectangle with given points lie inside in C++
- How to generate array of n equidistant points along a line segment of length x with JavaScript?
- Find the value (s) of $k$ for which the points $(3k â€“ 1, k â€“ 2), (k, k â€“ 7)$ and $(k â€“ 1, -k â€“ 2)$ are collinear.
- Generate a Vandermonde matrix of given degree with float array of points in Python