FZU 2110  Star

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

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;
}

  

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

  1. nyoj--1011--So Easy[II](数学几何水题)

    So Easy[II] 时间限制:1000 ms  |  内存限制:65535 KB 难度:2 描述 这是一道基础的计算几何问题(其实这不提示大家也都看的出).问题描述如下: 给你一个N边形.且N边形 ...

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

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  3. HDU 2674 N!Again(数学思维水题)

    题目 //行开始看被吓一跳,那么大,没有头绪, //看了解题报告,发现这是一道大大大的水题,,,,,//2009 = 7 * 7 * 41//对2009分解,看它有哪些质因子,它最大的质因子是41,那 ...

  4. HDU ACM 1073 Online Judge -&gt;字符串水题

    分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read ...

  5. UVa 12230 && HDU 3232 Crossing Rivers (数学期望水题)

    题意:你要从A到B去上班,然而这中间有n条河,距离为d.给定这n条河离A的距离p,长度L,和船的移动速度v,求从A到B的时间的数学期望. 并且假设出门前每条船的位置是随机的,如果不是在端点,方向也是不 ...

  6. ACM: FZU 2102 Solve equation - 手速题

     FZU 2102   Solve equation Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & ...

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

    POJ 1401 Factorial Time Limit:1500MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu   ...

  8. FZU 2110 Star

    简单暴力题,读入%lld会WA,%I64d能过. #include<cstdio> #include<cstring> #include<cmath> #inclu ...

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

    Description Master LU 非常喜欢数学,现在有个问题:在二维空间上一共有n个点,LU每连接两个点,就会确定一条直线,对应有一个斜率.现在LU把平面内所有点中任意两点连线,得到的斜率放 ...

随机推荐

  1. logo

  2. Web开发技术发展历史

    Web开发技术发展历史   来自:天码营 原文:http://www.tianmaying.com/tutorial/web-history Web的诞生 提到Web,不得不提一个词就是"互 ...

  3. Python之路【第二十一篇】Django ORM详解

    ORM回顾 关系对象映射(Object Relational Mapping,简称ORM). django中遵循 Code Frist 的原则,即:根据代码中定义的类来自动生成数据库表. 对于ORM框 ...

  4. 巧用setTimeout解决阻塞导致页面无法重绘

    项目中遇到一个javascript问题,大致如下: <!doctype HTML> <html> <head> <meta charset="utf ...

  5. 关于跨域名的信息共享P3P实例

    首先我这里用到了redis 和 p3p技术.当然任意的nosql都可以满足 模拟的一个登陆访问的客户端. <?php session_start(); $get = $_GET; ') { $t ...

  6. [Linux & Mysql] Linux下Mysql的基本操作

    1. 连接Mysql 1.1 连接到本机上的Mysql 键入命令mysql -u root -p,回车后提示你输密码.注意用户名前可以有空格也可以没有空格,但是密码前必须没有空格,否则让你重新输入密码 ...

  7. memcache与memcached的区别

    其实到底说成什么无所谓,只要你真正理解和知道使用就可以了!但是介于有和我一样学习时遇到的这个疑惑,在此分享下其中的缘由: Memcache是一个软件 Memcache是一个自由和开放源代码.高性能.分 ...

  8. Win10安装程序出现error code 2502 2503

    在Win10中,在安装msi安装包的时候常常会出现代码为2502.2503的错误.其实这种错误是由于安装权限不足造成的,可以这种msi的安装包不像其他exe的安装程序,在安装包上点击"右键& ...

  9. Linux Swap分区设定

    因为准备在linux上面安装Oracle数据库,据说swap分区小于4G容易失败,天啦噜的我连swap分区是啥都不是非常清楚, 大概有个印象吧,但先搞大了再说. 测试证明Ubuntu14默认的swap ...

  10. JavaScript方法

    1.hasOwnProperty:是用来判断一个对象是否有你给出名称的属性或对象.不过需要注意的是,此方法无法检查该对象的原型链中是否具有该属性,该属性必须是对象本身的一个成员.isPrototype ...