ACM--计算几何--FZU--2110--Star
来源:互联网 发布:linux netstat an 编辑:程序博客网 时间:2024/05/16 03:57
题目oj地址:http://acm.fzu.edu.cn/problem.php?pid=2110
Problem 2110 Star
Accept: 852 Submit: 2543
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
=================================傲娇的分割线============================
题意:给你一些点,计算这些点能组成多少个锐角三角形。
此题最重要的判断条件是锐角三角形计算公式:a*a+b*b>c*c (两边之间的距离大于第三边)
直接使用暴力破解,进行三次循环
<pre name="code" class="cpp">#include <iostream>using namespace std;typedef struct Point{ double x,y;}Point;Point point[110];/** 此题最重要的判断条件是 锐角三角形计算公式:a*a+b*b>c*c (两边之间的距离大于第三边) 直接使用暴力破解,进行三次循环*/int main(){ int n; cin>>n; int i,j,k; while(n--){ int m; cin>>m; int result=0; double a,b,c;//构成三角形的三条边的长度 //将所有的点录入进point数组中 for(i=0;i<m;i++){ cin>>point[i].x; cin>>point[i].y; } //三个循环 for(i=0;i<m;i++){ for(j=i+1;j<m;j++){ for(k=j+1;k<m;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[j].x-point[k].x)*(point[j].x-point[k].x)+ (point[j].y-point[k].y)*(point[j].y-point[k].y);//计算两点之间的距离 if(a+b>c&&a+c>b&&b+c>a){//两边之和大于第三边 result++; } } } } cout<<result<<endl; } return 0;}
参考博客:http://blog.csdn.net/whjkm/article/details/45897521
1 0
- ACM--计算几何--FZU--2110--Star
- FZU OJ 2110 Star (计算几何)
- FZU 2110Star(计算几何)
- FZU 2110Star(计算几何)
- FZU - 2110 Star(几何)
- FZU Problem 2110 Star
- FZU 2110 Star
- FZU 2110 Star
- FZU - 2110 Star
- FZU - 2110 Star
- FZU-2110-Star
- fzu 2110 Star(枚举)
- fzu 2110 star 结构体
- fzu 2273 Triangles 计算几何
- ACM计算几何推荐
- ACM计算几何模板
- ACM计算几何
- ACM计算几何推荐
- 读写配置文件代码块
- Tricks(三十九)—— 使用 list comprehension 构造笛卡尔积
- Cannot update object that was never inserted
- PERCONA-TOOLKIT 工具的安装与使用
- 调整CentOS 7中yum仓库的优先级
- ACM--计算几何--FZU--2110--Star
- 大数据时代下数据重删的考虑
- BestCoder #81 Div2 C String(尺取法)
- 幻数浅析(Magic Number)
- 数据结构二叉树
- Hibernate连接各种数据库的配置
- AndroidStudio 如何使用JNI
- php数据类型
- Java IO流总结(2)