http://acm.hdu.edu.cn/showproblem.php?pid=5784

题意:n个点,找多少个锐角三角形数目

思路:极角排序+two pointers

当前选择的点集要倍增一倍,点集过大时,极角排序后,后面的点有可能和前面的点形成钝角

ans=总的三角形数目 - 三点共线的情况-直角和钝角

 // #pragma comment(linker, "/STACK:102c000000,102c000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
// #include <conio.h>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define lson l,mid,rt<<1
// #define rson mid+1,r,rt<<1|1
const int N = ;
const int M = 1e6+;
const int MOD = 1e9+;
#define LL long long
#define LB long double
// #define mi() (l+r)>>1
double const pi = acos(-);
const double eps = 1e-;
void fre(){freopen("in.txt","r",stdin);}
inline int read(){int x=,f=;char ch=getchar();while(ch>''||ch<'') {if(ch=='-') f=-;ch=getchar();}while(ch>=''&&ch<='') { x=x*+ch-'';ch=getchar();}return x*f;} struct Point{
LL x,y;
Point(){}
Point(LL _x,LL _y):x(_x),y(_y){}
Point operator + (const Point &t)const{
return Point(x+t.x,y+t.y);
}
Point operator - (const Point &t)const{
return Point(x-t.x,y-t.y);
}
LL operator * (const Point &t)const{
return x*t.y-y*t.x;
}
LL operator ^ (const Point &t)const{
return x*t.x+y*t.y;
}
bool operator < (const Point &b)const{
if (y * 1LL * b.y <= ) {
if (y > || b.y > ) return y < b.y;
if (y == && b.y == ) return x < b.x;
}
return (*this)*b > ;
}
}p[N],v[N<<]; int main(){
int n;
while(~scanf("%d",&n)){
for(int i=;i<n;i++) scanf("%I64d%I64d",&p[i].x,&p[i].y);
LL ans=1LL*n*(n-)*(n-)/,tem=;
for(int k=;k<n;k++){
int cnt=;
for(int i=;i<n;i++){
if(k==i)continue;
v[cnt++]=p[i]-p[k];
}
sort(v,v+cnt);
for(int i=;i<cnt;i++) v[i+cnt]=v[i];
int cxt=;
for(int i=;i<cnt;i++){
if(v[i-]*v[i]==&&(v[i-]^v[i])>) cxt++;
else cxt=;
tem+=cxt;
}
for(int i=,p1=,p2=;i<cnt;i++){
while(p1<=i||(p1<i+cnt&&v[p1]*v[i]<&&(v[p1]^v[i])>)) p1++;
while(p2<=i||(p2<i+cnt&&v[p2]*v[i]<)) p2++;
ans-=p2-p1;
}
}
printf("%I64d\n",ans-tem/);
}
return ;
}

多校5 1004 HDU5784 统计锐角三角形数目的更多相关文章

  1. HDU 4669 Mutiples on a circle (2013多校7 1004题)

    Mutiples on a circle Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Oth ...

  2. HDU 4699 Editor (2013多校10,1004题)

    Editor Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Su ...

  3. HDU 4679 Terrorist’s destroy (2013多校8 1004题 树形DP)

    Terrorist’s destroy Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Othe ...

  4. HDU 4658 Integer Partition (2013多校6 1004题)

    Integer Partition Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  5. Linux统计文件数目

    统计当前目录下文件数目 $ find . -type f | wc -l 统计文件行数 $ wc -l filename 仅统计内容为pattern的行(只有pattern) $ grep -w &q ...

  6. C语言实现二叉树-利用二叉树统计单词数目

    昨天刚参加了腾讯2015年在线模拟考: 四道大题的第一题就是单词统计程序的设计思想: 为了记住这一天,我打算今天通过代码实现一下: 我将用到的核心数据结构是二叉树: (要是想了解简单二叉树的实现,可以 ...

  7. MapReduce流程、如何统计任务数目以及Partitioner

    核心功能描述 应用程序通常会通过提供map和reduce来实现 Mapper和Reducer接口,它们组成作业的核心. Map是一类将输入记录集转换为中间格式记录集的独立任务. 这种转换的中间格式记录 ...

  8. Linux 命令 统计进程数目

    ps -efL | grep python | wc -l 此命令的意思是查看 Python的进程数目 ps -ef|grep python|grep -v grep|cut -c -|xargs k ...

  9. HDU 4635 Strongly connected (2013多校4 1004 有向图的强连通分量)

    Strongly connected Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

随机推荐

  1. Hibernate逍遥游记-第12章 映射值类型集合-004映射Map(<map-key>)

    1. 2. <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate ...

  2. JS中用execCommand("SaveAs")保存页面兼容性问题解决方案

    开发环境:ASP.NET MVC,其他环境仅供参考. 问题描述:在开发中遇到这样的需求,保存页面,通常使用JavaScript的saveAs进行保存,各浏览器对saveAs支持,见下表. 代码一:初始 ...

  3. C++:运算符重载函数之"++"、"--"、"[ ]"、"=="的应用

    5.2.5 "++"和"--"的重载 对于前缀方式++ob,可以用运算符函数重载为: ob.operator++() //成员函数重载 或 operator++ ...

  4. JDBC学习总结(四)

    JDBC对LOB的读写 在JDBC中提供了java.sql.Blob和java.sql.Clob,两个类分别代表BLOB和CLOB数据.         · BLOB(Binary Large Obj ...

  5. PHP Redis 普通封装类

    class redisInit { private $redis; //redis对象 /** * 初始化Redis * $config = array( * 'server' => '127. ...

  6. C++ 11 vlearning

    1.新增算术类型     longlong,最小不比long小,一般为64位. 2.列表初始化      int units_sold = {0};或者 int units_sold{0};非11标准 ...

  7. [Codeforces670A]Holidays(数学,构造)

    题目链接:http://codeforces.com/contest/670/problem/A 题意:给n天,问这n天最少和最多有多少个休息日,不用区分平闰年. 这题写几个例子,YY一下就构造出来解 ...

  8. MyEclipse中使用JUnit进行单元测试

    1. 下载JUnit的jar文件,下载地址在这里 2. 在MyEclipse中新建一个要测试的项目HelloJUnit 3. 添加一个要测试的类HelloJUnit,代码如下,注意需要先建packag ...

  9. poj 1067 取石子游戏( 威佐夫博奕)

    题目:http://poj.org/problem?id=1067 题意:有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的 ...

  10. UVa 11330 (置换 循环的分解) Andy's Shoes

    和UVa11077的分析很类似. 我们固定左脚的鞋子不动,然后将右脚的鞋子看做一个置换分解. 对于一个长度为l的循环节,要交换到正确位置至少要交换l-1次. #include <cstdio&g ...