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 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

题意:给你一些点,计算这些点能组成多少个锐角三角形。

锐角三角形计算公式:a*a+b*b>c*c (两边之间的距离大于第三边)

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef struct Point
{
    double x,y;
}Point;
Point point[160];
int main()
{
    int ans, t, i, j, k, n;
    double a,b,c;
    cin >> t;
    while (t--)
    {
        cin >> n;
        for (i=0; i<n; i++)
        {
            cin >> point[i].x >> point[i].y;
        }
        ans = 0;
        for (i=0; i<n-2; i++)//利用三重循环每次计算三个点之间的关系
        {
            for (j=i+1; j<n-1; j++)
            {
                for (k=j+1; k<n; k++)
                {
                    a = (point[i].x-point[j].x)*(point[i].x-point[j].x) + (point[i].y-point[j].y)*(point[i].y-point[j].y);//计算两点之间的距离
                    b = (point[i].x-point[k].x)*(point[i].x-point[k].x) + (point[i].y-point[k].y)*(point[i].y-point[k].y);
                    c = (point[k].x-point[j].x)*(point[k].x-point[j].x) + (point[k].y-point[j].y)*(point[k].y-point[j].y);

                    if (a+b>c && a+c>b && c+b>a) //三点都满足才是锐角三角形
                    {
                        ans++;
                    }

                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}
时间: 2024-12-26 12:26:01

FZU OJ 2110 Star (计算几何)的相关文章

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

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,

hrbust oj 1025 (计算几何+近似计算)

这是我第一次只要可以这么做,题目中给的精度范围较大,所以可以把圆形的区域直接用小方块拼接近似来表示,maps地图开的越大,精度越高,但同时耗时也更多. 代码如下: #include<cstdio> #include<iostream> #include<cstring> using namespace std; int main() { double x,y,r; int maps[101][101],num,i,j,n; while(~scanf("%d&q

FZU OJ 2140 Forever 0.5 (几何)

Problem 2140 Forever 0.5 Accept: 269    Submit: 934    Special Judge Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Given an integer N, your task is to judge whether there exist N points in the plane such that satisfy the follo

FZU OJ 2147 A-B Game (数学水题)

Problem 2147 A-B Game Accept: 827    Submit: 1940 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Fat brother and Maze are playing a kind of special (hentai) game by two integers A and B. First Fat brother write an integer A on

FZU OJ 2111 Min Number (贪心)

Problem 2111 Min Number Accept: 586    Submit: 1139 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Now you are given one non-negative integer n in 10-base notation, it will only contain digits ('0'-'9'). You are allowed to choo

ZOJ 3521 Fairy Wars oj错误题目,计算几何,尺取法,排序二叉树,并查集 难度:2

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3521 ATTENTION:如果用long long 减小误差,这道题只能用%lld读入 首先需要判断哪些点是相互挨着的,这样比直接维护哪些集合是冰冻住的简单 按照x为主,y为辅排序,在数组上尺取,当head与tail的x坐标相差大于l/2则把head向后移动直到x坐标满足条件, 那么对于head到tail,现在的问题就只剩下检测出哪些点之间y间距小于l/2,把它们都按照p

[思路题+贪心] fzu oj 2197 最小花费

题意: 给一个01串,相邻的01交换代价为X,否则为Y. 问把全部1变到0前面的最小费用. 思路: 对于 01011->11100 如果只靠相邻位移动是需要5步的. 然而不管怎么移动,步数是固定的. 那我们就把最前面的0和最后面的1交换 假设0在i,1在j.我们交换的代价就是min(y,x*(j-i)) 然后累加求和就好了! 很棒的脑洞题! 代码: #include"cstdlib" #include"cstdio" #include"cstring