Fzu problem 2110 Star (math AH)

Source: Internet
Author: User
Tags acos

Title Link: http://acm.fzu.edu.cn/problem.php?pid=2110


Problem Descriptionoverpower often go to the playground with classmates. They play and chat on the playground. One day, there is a lot of stars in the sky. Suddenly, one of overpower's classmates ask him: "How many acute triangles whose inner angles is less than" degrees (re Garding stars as points) can be found? Assuming all the stars is in the same plane ". him to solve this problem. Input

The first line of the input contains an integer T (t≤10), indicating the number of the test cases.

For each test case:

The first line contains one integer n (1≤n≤100), the number of stars.

The next n lines each contains a integers x and y (0≤|x|, |y|≤1,000,000) indicate the points, all the points is distinc T.

Outputfor each test case, output a integer indicating the total number of different acute triangles. Sample Input130 010 Output1 Source "Higher Education Cup" the third Fujian University student Program Design Contest
Test Instructions:

How many acute triangle are you looking for?

The code is as follows:

#include <cstdio> #include <cstring> #include <cmath>const double Pi=acos ( -1.0), struct node{double x, Y;} A[1017];d ouble init (Node A, Node B) {return sqrt ((a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-B.Y));}    BOOL OK (double a,double b,double c) {double aa,bb,cc;    Cc=acos ((a*a+b*b-c*c)/(2*a*b));    Bb=acos ((a*a+c*c-b*b)/(2*a*c));    Aa=acos ((b*b+c*c-a*a)/(2*b*c));    if (cc<pi/2.0 && aa<pi/2.0 && bb<pi/2.0) return 1; return 0;}    int main () {int t;    int n;    scanf ("%d", &t);        while (t--) {scanf ("%d", &n);        for (int i = 0; i < n; i++) {scanf ("%lf%lf", &a[i].x,&a[i].y);        } int ans=0; for (int i = 0, i < n; i++) {for (int j = i+1; J < N; j + +) {for (int k = j+1; K < n;                    k++) {Double AA = init (a[i],a[j]);                    Double BB = init (a[i],a[k]); Double cc = INIt (A[j],a[k]);                if (OK (AA,BB,CC)) ans++;    }}} printf ("%d\n", ans); } return 0;}


Fzu problem 2110 Star (math AH)

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.