Find three vertices in an N | C ++ program for the above approach ; Function to find three vertices that subtends an angle closest to A ; Stores the closest angle to A ; Stores the count of edge which subtend an angle of A ; Iterate in the range [ 1 , N - 2 ] ; Stores the angle subtended ; If absolute ( angle - A ) is less than absolute ( mi - A ) ; Update angle to mi , and also update i to ans ; Print the vertices ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; #define ll  long long NEW_LINE #define MAXN  1000000 NEW_LINE void closestsAngle ( int N , int A ) { double mi = INT_MAX ; int ans = 0 ; for ( int i = 1 ; i < N - 1 ; i ++ ) { double angle = 180.0 * i / N ; if ( fabs ( angle - A ) < fabs ( mi - A ) ) { mi = angle ; ans = i ; } } cout << 2 << ' ▁ ' << 1 << ' ▁ ' << 2 + ans ; } int main ( ) { int N = 3 , A = 15 ; closestsAngle ( N , A ) ; return 0 ; }