Triangles, triangle

Source: Internet
Author: User

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 );}}

 

 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.