FOJ 2110 Star
来源:互联网 发布:电脑网络端口的数据 编辑:程序博客网 时间:2024/05/16 17:18
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, b, c三条边,a^2+b^2<c^2&&a^2+c^2<b^2&&c^2+b^2<a^2即可
AC代码:
# include <stdio.h>typedef long long int ll;struct node {ll x, y;};node s[110];ll func(node a, node b){return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}int main(){int t, n, i, j, k;ll a, b, c;scanf("%d", &t);while(t--){scanf("%d", &n);for(i=1; i<=n; i++){scanf("%I64d%I64d", &s[i].x, &s[i].y);}if(n<=2){printf("0\n");continue;}int ans=0;for(i=1; i<=n-2; i++){for(j=i+1; j<=n-1; j++){for(k=j+1; k<=n; k++){a=func(s[i], s[j]);b=func(s[i], s[k]);c=func(s[j], s[k]);if(a+b>c&&a+c>b&&b+c>a){ans++;}}}}printf("%d\n", ans);}return 0;}
0 0
- FOJ 2110 Star
- FZU Problem 2110 Star
- FZU 2110 Star
- FZU 2110 Star
- FZU - 2110 Star
- FZU - 2110 Star
- FZU-2110-Star
- Star
- Star
- Star
- star
- star
- fzu 2110 Star(枚举)
- FZU - 2110 Star(几何)
- fzu 2110 star 结构体
- FZU Problem 2110 Star (数学啊 )
- FZU OJ 2110 Star (计算几何)
- FZU 2110Star(计算几何)
- PHP接口开发加密技术实例原理与例子
- BZOJ 1001, 狼抓兔子
- 剑指Offer_14_链表中倒数第k个结点
- eclipse的groovy插件版本集合(支持不同版本的eclipse)
- HUST 1017 Exact cover(舞蹈链 入门题)(模板记录)
- FOJ 2110 Star
- #374 Spiral Matrix
- iOS_TCBlobDownload接入
- 【IOS移动开发技术】github上IOS开发优秀开源项目大全
- 四旋翼位置控制之-GPS水平位置控制
- jQuery $.each用法
- 82. Remove Duplicates from Sorted List II
- [Android问答] px、dp和sp,这些单位有什么区别?
- 并发编程四:Synchronized关键字