本文主要是介绍FOJ 2110 Star,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Problem Description
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
Sample Input
Sample Output
# 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;
}
这篇关于FOJ 2110 Star的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!