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

求锐角三角形的个数;

数学结论 : 锐角三角形 任意边满足 a^2<b^2+c^2 ;

AC代码:
#include"algorithm"
#include"iostream"
#include"cstring"
#include"cstdlib"
#include"cstdio"
#include"string"
#include"vector"
#include"stack"
#include"queue"
#include"cmath"
#include"map"
using namespace std;
typedef long long LL ;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define FK(x) cout<<"["<<x<<"]\n"
#define memset(x,y) memset(x,y,sizeof(x))
#define memcpy(x,y) memcpy(x,y,sizeof(x))
#define bigfor(T)  for(int qq=1;qq<= T ;qq++)

struct Star {
	LL x;
	LL y;
} st[200];

bool cmp(LL a,LL b) {
	return a>b;
}

bool check(int i,int j,int k) {
	LL s[3];
	s[0]=(st[i].x-st[j].x)*(st[i].x-st[j].x)+(st[i].y-st[j].y)*(st[i].y-st[j].y);
	s[1]=(st[i].x-st[k].x)*(st[i].x-st[k].x)+(st[i].y-st[k].y)*(st[i].y-st[k].y);
	s[2]=(st[k].x-st[j].x)*(st[k].x-st[j].x)+(st[k].y-st[j].y)*(st[k].y-st[j].y);
//	FK(s[0]);
//	FK(s[1]);
//	FK(s[2]);
	sort(s,s+3,cmp);
	if(s[0]<s[1]+s[2])return 1;
	return 0;
}

int main() {
	int T;
	int n;
	scanf("%d",&T);
	bigfor(T) {
		scanf("%d",&n);
		for(int i=0; i<n; i++) {
			scanf("%I64d%I64d",&st[i].x,&st[i].y);
		}
		LL ans=0;
		for(int i=0; i<n; i++) {
			for(int j=i+1; j<n; j++) {
				for(int k=j+1; k<n; k++) {
					if(check(i,j,k)) ans++;
				}
			}
		}
		printf("%I64d\n",ans);
	}
	return 0;
}

  

时间: 2024-10-17 07:31:18

ACM: FZU 2110 Star - 数学几何 - 水题的相关文章

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,

[ACM] Color the ball [线段树水题][数组开大]

Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的"小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色.但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗? Input 每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(1 <= a <= b <= N).  当N

ACM :漫漫上学路 -DP -水题

CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit Status Description 对于csuxushu来说,能够在CSU(California State University)上学是他一生的荣幸.CSU校园内的道路设计的十分精巧,由n+1条水平道路和n+1条竖直道路等距交错而成,充分体现了校园深厚的文化底蕴.然而不幸的是CS市每到夏季,天降大雨,

UVa 12230 Crossing Rivers (数学期望水题)

题意:你要从A到B去上班,然而这中间有n条河,距离为d.给定这n条河离A的距离p,长度L,和船的移动速度v,求从A到B的时间的数学期望. 并且假设出门前每条船的位置是随机的,如果不是在端点,方向也是不定的,你在陆地行走速度为1,输入保证河在AB之前,并且不会重叠. 析:一看这个题,好像不会啊...这怎么求,这么乱,这么复杂... 但是仔细一想求时间期望,不就是在过河的地方时间不是固定的么,只要求出过河的时间的数学期望,利用数学期望的线性,加起来就OK了. 这样一想感觉就不乱了,那么怎么求每个河的

C 几何水题 求不同斜率的数目 枚举+set

Description Master LU 非常喜欢数学,现在有个问题:在二维空间上一共有n个点,LU每连接两个点,就会确定一条直线,对应有一个斜率.现在LU把平面内所有点中任意两点连线,得到的斜率放入一个集合中(若斜率不存在则不计入集合),他想知道这个集合中有多少个元素. Input 第一行是一个整数T,代表T组测试数据每组数据第一行是一个整数n,代表点的数量.2<n<1000接下来n行,每行两个整数,0<=x<10000,0<=y<10000,代表点的坐标 Outp

ACM: FZU 2102 Solve equation - 手速题

FZU 2102   Solve equation Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Practice Description You are given two positive integers A and B in Base C. For the equation: A=k*B+d We know there always existing many non-negati

ACM: POJ 1401 Factorial-数论专题-水题

POJ 1401 Factorial Time Limit:1500MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Description The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term

LA 7359 Sum Kind Of Problem (数学,水题)

题意:给定一个n,求前 n 个正整数,正奇数,正偶数之和. 析:没什么好说的,用前 n 项和公式即可. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include

HDU ACM 1039 Easier Done Than Said? 水题

分析:判断密码是否安全. 三个条件:至少一个元音字母,连续三个字母不能同时为元音或辅音,连续两个字母不能相同,但"ee"和"oo"除外. #include<iostream> using namespace std; bool isyuan(char c) { return c=='a' || c=='e' || c=='i' || c=='o' || c=='u'; } bool judge(char a[]) { int i,l; l=strlen(