多校5 1004 HDU5784 统计锐角三角形数目
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 统计锐角三角形数目的更多相关文章
- 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 ...
- HDU 4699 Editor (2013多校10,1004题)
Editor Time Limit: 3000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Su ...
- 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 ...
- HDU 4658 Integer Partition (2013多校6 1004题)
Integer Partition Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- Linux统计文件数目
统计当前目录下文件数目 $ find . -type f | wc -l 统计文件行数 $ wc -l filename 仅统计内容为pattern的行(只有pattern) $ grep -w &q ...
- C语言实现二叉树-利用二叉树统计单词数目
昨天刚参加了腾讯2015年在线模拟考: 四道大题的第一题就是单词统计程序的设计思想: 为了记住这一天,我打算今天通过代码实现一下: 我将用到的核心数据结构是二叉树: (要是想了解简单二叉树的实现,可以 ...
- MapReduce流程、如何统计任务数目以及Partitioner
核心功能描述 应用程序通常会通过提供map和reduce来实现 Mapper和Reducer接口,它们组成作业的核心. Map是一类将输入记录集转换为中间格式记录集的独立任务. 这种转换的中间格式记录 ...
- Linux 命令 统计进程数目
ps -efL | grep python | wc -l 此命令的意思是查看 Python的进程数目 ps -ef|grep python|grep -v grep|cut -c -|xargs k ...
- HDU 4635 Strongly connected (2013多校4 1004 有向图的强连通分量)
Strongly connected Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
随机推荐
- AsyncTask 与 Thread+Handler
AsyncTask是封装好的线程池,比起Thread+Handler的方式,AsyncTask在操作UI线程上更方便,因为onPreExecute().onPostExecute()及更新UI方法on ...
- iOS 相机和相册使用授权
1.判断用户是否有权限访问相册 授权一次后,不在提示是否授权 #import <AssetsLibrary/AssetsLibrary.h> ALAuthorizationStatus a ...
- [cocoapods] 如何卸载工程里的cocoapods
1. 打开自己的工程所在文件夹 删除这4个文件 2. 打开工程,把红线的东西都删除掉 3. 只留下原来的4个,其余都删除掉
- bootstrap 3.x笔记
布局容器 Bootstrap 需要为页面内容和栅格系统包裹一个 .container 容器.我们提供了两个作此用处的类.注意,由于 padding等属性的原因,这两种 容器类不能互相嵌套. .cont ...
- 今日思考:MVC系列框架之Struts存在的意义是什么?
Struts其实就是MVC的代名词,那么提到MVC就不得不提早期的ModelⅠ.那时候JSP页面中混杂了大量的JAVA Scriptlet脚本语句,为了可维护性考虑,有人提出了ModelⅡ,也即现在的 ...
- Android中的多线程
final Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.han ...
- 在Linux中创建静态库和动态库
我们通常把一些公用函数制作成函数库,供其它程序使用. 函数库分为静态库和动态库两种. 静态库在程序编译时会被连接到目标代码中,程序运行时将不再需要该静态库. 动态库在程序编译时并不会被连接到目标代码中 ...
- (一)CSS三种插入方式
CSS概述 CSS(Cascading Style Sheets)指层叠样式表,样式定义了如何显示HTML元素. 样式通常存储在样式表中,样式与HTML分离解决了内容与表现分离的问题. 多个样式表可以 ...
- iOS学习笔记:frame,bound,center, anchorPoint
frame: View在它的Super View坐标系里的坐标 bound: 用来定义View自身坐标系和边界的Rect,Rect的原点表示View自身坐标系的原点坐标.举个例子: 一般情况下boun ...
- uva 10131 Is Bigger Smarter ? (简单dp 最长上升子序列变形 路径输出)
题目链接 题意:有好多行,每行两个数字,代表大象的体重和智商,求大象体重越来越大,智商越来越低的最长序列,并输出. 思路:先排一下序,再按照最长上升子序列计算就行. 还有注意输入, 刚开始我是这样输入 ...