FZU Problem 2110 Star (数学啊 )

题目链接:http://acm.fzu.edu.cn/problem.php?pid=2110

Problem Description

Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sky. Suddenly, one of Overpower’s classmates ask him: “How many acute triangles whose inner angles are
less than 90 degrees (regarding stars as points) can be found? Assuming all the stars are in the same plane”. Please help him to solve this problem.

Input

The first line of the input contains an integer T (T≤10), indicating the number of 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 two integers x and y (0≤|x|, |y|≤1,000,000) indicate the points, all the points are distinct.

Output

For each test case, output an integer indicating the total number of different acute triangles.

Sample Input

130 010 05 1000

Sample Output

1

Source

“高教社杯”第三届福建省大学生程序设计竞赛

题意:

找有多少个锐角三角形!

代码如下:

#include <cstdio>
#include <cstring>
#include <cmath>
const double PI=acos(-1.0);
struct node
{
    double x, y;
}a[1017];
double 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;
}
时间: 2024-08-01 22:45:21

FZU Problem 2110 Star (数学啊 )的相关文章

FZU OJ 2110 Star (计算几何)

Problem 2110 Star Accept: 585    Submit: 1731 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the s

ACM: FZU 2110 Star - 数学几何 - 水题

FZU 2110  Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Practice Description Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sky.

FZU 2110 Star 数学

Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u FZU 2110 Description Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sky. Suddenly,

FZU Problem 2171 防守阵地 II (线段树,区间更新)

 Problem 2171 防守阵地 II Accept: 143    Submit: 565Time Limit: 3000 mSec    Memory Limit : 32768 KB  Problem Description 部队中总共有N个士兵,每个士兵有各自的能力指数Xi,在一次演练中,指挥部确定了M个需要防守的地点,指挥部将选择M个士兵依次进入指定地点进行防守任务,获得的参考指数即为M个士兵的能力之和.随着时间的推移,指挥部将下达Q个指令来替换M个进行防守的士兵们,每个参加完防守

FZU Problem 2034 Password table (简单模拟题)

这种简单题做了好长时间,我是不是有点逗? 地址:http://acm.fzu.edu.cn/problem.php?pid=2034 不解释了,自己看吧,练手的好题 上个代码吧 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 #include <stdio.h> #include <string.h> #include <stdlib.h>

FZU Problem 2238 Daxia &amp; Wzc&#39;s problem

Daxia在2016年5月期间去瑞士度蜜月,顺便拜访了Wzc,Wzc给他出了一个问题: Wzc给Daxia等差数列A(0),告诉Daxia首项a和公差d; 首先让Daxia求出数列A(0)前n项和,得到新数列A(1); 然后让Daxia求出数列A(1)前n项和,得到新数列A(2); 接着让Daxia求出数列A(2)前n项和,得到新数列A(3); 规律题,首先写出 a.a+d.a+2d.a+3d...这个容易写出 下面一行也容易写出:a.2a+d.3a+3d.... 再下一行,确实难写,但是通过上

FZU Problem 2168 防守阵地 I

http://acm.fzu.edu.cn/problem.php?pid=2168 题目大意: 给定n个数和m,要求从n个数中选择连续的m个,使得a[i]*1+a[i+1]*2+--a[i+m]*m最大 思路: 常规思路是以每个数开始,枚举m个,但是这样会TLE. 可以有O(n)的算法. 例如样例的 n=5 m=3 五个数分别为 2 1 3 1 4 有三种连续的三个数 2 * 1 + 1 * 2 + 3* 3 = 13 1 * 1 + 3 * 2 + 1 * 3= 10 3 * 1 + 1 *

FZU Problem 2169 shadow

http://acm.fzu.edu.cn/problem.php?pid=2169 题目大意: S王国有N个城市,有N-1条道路.王都为编号1的城市.叛军驻扎在许多城市.除了王都外有K个城市有军队,这K支军队要向王都进军,并且消灭沿途经过的城市中的叛军.每支军队只能沿着道路走,并且是其所在城市与王都之间的最短路线走.问能够消灭多少叛军? 思路: 有两种方法. 注意到题目只有N-1条边.是一颗树. 我想到的是对编号为1的结点(也就是王都,作为跟结点)进行DFS,一直遍历到树叶为止.沿途若发现有军

FZU Problem 2062 Suneast &amp; Yayamao

http://acm.fzu.edu.cn/problem.php?pid=2062 题目大意: 给你一个数n,要求求出用多少个数字可以表示1~n的所有数. 思路: 分解为二进制. 对于一个数n,看它二进制有多少位即可. #include<cstdio> int main() { int n; while(~scanf("%d",&n)) { int k=0; while(n) { n>>=1; k++; } printf("%d\n"