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. 腾讯QQ的开发分客户端软件和服务器端软件

    Windows客户端主要是C++ COM/ATL Q+Web 后端C++ CGI ,前端javascript和flash 望采纳 腾讯QQ使用何种开发平台? 腾讯QQ的开发分客户端软件和服务器端软件两 ...

  2. 40. Combination Sum II

    题目: Given a collection of candidate numbers (C) and a target number (T), find all unique combination ...

  3. Android Bundle的使用

    发送数据: Bundle bundle = new Bundle(); bundle.putString("sex" , "男人"); bundle.putDo ...

  4. mongodb 常见操作转

    Ø Collection聚集集合 1.创建一个聚集集合(table) db.createCollection(“collName”, {size: 20, capped: 5, max: 100}); ...

  5. [置顶] Android系统五大布局详解Layout

    我们知道Android系统应用程序一般是由多个Activity组成,而这些Activity以视图的形式展现在我们面前,视图都是由一个一个的组件构成的.组件就是我们常见的Button.TextEdit等 ...

  6. orzdba在5.6安装

    前言:淘宝的orzdba查看MySQL服务器当前QPS,TPS很方便,但是不少人反应,在5.6原本好用的工具不好用了,频繁出现这样警告: Warning: Using a password on th ...

  7. java服务器知识

    http://blog.csdn.net/chenyi8888/article/details/4484641 http://blog.csdn.net/chenyi8888/article/deta ...

  8. init_MUTEX

    2.6.25及以后的linux内核版本废除了init_MUTEX函数 新版本使用sema_init函数 平台:X86 32位内核:2.6.24定义: 引用 static inline void ini ...

  9. 【HDOJ】5632 Rikka with Array

    1. 题目描述$A[i]$表示二级制表示的$i$的数字之和.求$1 \le i < j \le n$并且$A[i]>A[j]$的$(i,j)$的总对数. 2. 基本思路$n \le 10^ ...

  10. Junit单元测试的实例

    进行单元测试的代码 package JunitTest; import org.junit.Test; public class Calculator { private static int res ...