Triangles, triangle
Problem Description it is known that the circumference of a circle isNPoints are dividedNSegment and other long arcs. Obtain any three points to form the number of acute angular triangles. Input
Multiple groups of data.
Each group of data has oneN (N ≤ 1000000 ).
Output outputs the number of different acute triangles for each group of data. Sample Input
345
Sample Output
105
Solutions
Calculate the number C (n, 3) of all triangles, subtract the number of right triangle and right triangle, and determine the number of C (n, 1) after a vertex ), the remaining two vertices are all on a semi-circle C (n/2, 2). Then, these three points are either right triangle or an even triangle.
That is: the number of requests = C (n, 3)-C (n, 1) * C (n/2) = n * (n-1) * (n-2) /(3*2*1)-(n/2) * (n/2-1)/2 * n.
The Code is as follows:
# Include <stdio. h> int main () {long n, m; while (scanf ("% lld", & n )! = EOF) {m = n * (n-1) * (n-2)/6-n/2*(n/2-1)/2 * n; printf ("% lld \ n", m );}}