FZU-2110-Star
来源:互联网 发布:商品数据分析管理书籍 编辑:程序博客网 时间:2024/05/18 09:43
I - Star
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit
Status
Practice
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, 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
1
3
0 0
10 0
5 1000
Sample Output
1
题意,第一行给出T,然后T组数据,每组数据第一行给出n,接下来n行给出n组坐标,输出这n个点能构成的锐角三角形个数。
思路:通过坐标得到三边大小,然后判断锐角三角形任意两边平方和大于第三边平方。
三层for循环暴力枚举即可
代码
#include<iostream>#include<algorithm>#include<math.h>#include<string>#include<string.h>#include<stdio.h>#include<queue>using namespace std;int main(){ int T; scanf("%d",&T); while(T--) { int n;//n组数据 scanf("%d",&n); double num[2][105];//存储坐标 for(int i=0; i<n; i++) scanf("%lf%lf",&num[0][i],&num[1][i]);//存储x,y坐标 double a,b,c;//三角形三条边 int sum=0;//记录总数 for(int i=0; i<n-2; i++) for(int j=i+1; j<n-1; j++) for(int k=j+1; k<n; k++) { a=sqrt((num[0][i]-num[0][j])*(num[0][i]-num[0][j])+(num[1][i]-num[1][j])*(num[1][i]-num[1][j])); b=sqrt((num[0][i]-num[0][k])*(num[0][i]-num[0][k])+(num[1][i]-num[1][k])*(num[1][i]-num[1][k])); c=sqrt((num[0][k]-num[0][j])*(num[0][k]-num[0][j])+(num[1][k]-num[1][j])*(num[1][k]-num[1][j])); if(a*a+b*b>c*c&&a*a+c*c>b*b&&b*b+c*c>a*a) sum++; } printf("%d\n",sum); } return 0;}
注意数据精度
- 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 2110 star 结构体
- FZU Problem 2110 Star (数学啊 )
- FZU OJ 2110 Star (计算几何)
- FZU 2110Star(计算几何)
- FZU 2110Star(计算几何)
- ACM--计算几何--FZU--2110--Star
- FZU 2110
- FOJ 2110 Star
- Star
- Star
- html打开本地android app
- Android Audio 框架简读 <2>
- 在批处理模式下使用mysql
- 如何撰写创业计划书
- leetcode 24. Swap Nodes in Pairs
- FZU-2110-Star
- NOIP1999 Cantor表
- 【算法】插入排序
- excel到期提醒,可以用函数公式来做,颜色变化可以用条件格式来做。
- Js清除空白节点
- ATL CLR MFC Win32 常规 的区别--sdk与api的区别
- 字符串的一些问题总结
- Problem M
- 手动生成70-persistent-net.rules