hdu-5738 Eureka(组合计数+极角排序)
题目链接:
Eureka
Time Limit: 8000/4000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
A set P (P contains the label of the points) is called best set if and only if there are at least one best pair in P. Two numbers u and v (u,v∈P,u≠v) are called best pair, if for every w∈P, f(u,v)≥g(u,v,w), where f(u,v)=(xu−xv)2+(yu−yv)2−−−−−−−−−−−−−−−−−−−√ and g(u,v,w)=f(u,v)+f(v,w)+f(w,u)2.
The first line contains an integer n (1≤n≤1000) -- then number of points.
Each of the following n lines contains two integers xi and yi (−109≤xi,yi≤109) -- coordinates of the i-th point.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=1e5+10;
const int maxn=500+10;
const double eps=1e-9; int n,vis[1010];
LL fx,fy,f[1010];
struct node
{
double ang;
LL x,y;
}po[1010],temp[1010];
int cmp1(node a,node b)
{
return a.ang<b.ang;
}
int cmp(node a,node b)
{
if(a.y==b.y)return a.x<b.x;
return a.y<b.y;
} int main()
{
int t;
read(t);
f[0]=1;
For(i,1,1008)
{
f[i]=f[i-1]*2%mod;
}
while(t--)
{
read(n);
For(i,1,n)
{
read(po[i].x);read(po[i].y);
}
sort(po+1,po+n+1,cmp);
LL ans=0;
For(i,1,n-1)
{
int cnt=0,s=0;
For(j,i+1,n)
{
if(po[j].x==po[i].x&&po[j].y==po[i].y){s++;continue;}
temp[++cnt].ang=atan2(po[j].y-po[i].y,po[j].x-po[i].x);
temp[cnt].x=po[j].x;
temp[cnt].y=po[j].y;
}
sort(temp+1,temp+cnt+1,cmp1);
fx=po[i].x,fy=po[i].y;
int d=0;
for(int j=1;j<=cnt;)
{
int k,num=s+1;
for(k=j+1;k<=cnt;k++)
{
if((temp[k].y-fy)*(temp[j].x-fx)!=(temp[j].y-fy)*(temp[k].x-fx))break;
num++;
}
j=k;
ans=(ans+f[num]-1+mod)%mod;
d++;
}
ans=(ans-(LL)(d-1)*(f[s]-1+mod)%mod+mod)%mod;
}
cout<<ans<<endl;
}
return 0;
}
hdu-5738 Eureka(组合计数+极角排序)的更多相关文章
- HDU 5738 Eureka(极角排序)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5738 [题目大意] 给出平面中一些点,在同一直线的点可以划分为一个集合,问可以组成多少包含元素不少 ...
- hdu 5738 Eureka 极角排序+组合数学
Eureka Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...
- HDU 5738 Eureka 统计共线的子集个数
Eureka 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5738 Description Professor Zhang draws n poin ...
- HDU 5738 Eureka
传送门 题目大意: 给出平面上的$n$个点,每个点有唯一的标号($\text{label}$),这$n$个标号的集合记作$S$,点可能重合.求满足下列条件的$S$的子集$T$的数目: 1. $|T|\ ...
- 2017ACM暑期多校联合训练 - Team 7 1008 HDU 6127 Hard challenge (极角排序)
题目链接 Problem Description There are n points on the plane, and the ith points has a value vali, and i ...
- LA 4064 (计数 极角排序) Magnetic Train Tracks
这个题和UVa11529很相似. 枚举一个中心点,然后按极角排序,统计以这个点为钝角的三角形的个数,然后用C(n, 3)减去就是答案. 另外遇到直角三角形的情况很是蛋疼,可以用一个eps,不嫌麻烦的话 ...
- hdu 3908 Triple(组合计数、容斥原理)
Triple Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 125536/65536 K (Java/Others) Total Su ...
- [CF1025F]Disjoint Triangles[极角排序+组合计数]
题意 平面上有 \(n\) 个点,选出六个点构成两个三角形,问有多少种构造方式使得两个三角形没有交集. \(n\leq 2000\) 分析 枚举连接两个三角形的两个顶点,同时能够将两个三角形划分在直线 ...
- 【极角排序+双指针线性扫】2017多校训练七 HDU 6127 Hard challenge
acm.hdu.edu.cn/showproblem.php?pid=6127 [题意] 给定平面直角坐标系中的n个点,这n个点每个点都有一个点权 这n个点两两可以连乘一条线段,定义每条线段的权值为线 ...
随机推荐
- filter 中用spring StopWatch 监控请求执行时间
在filter中用spring stopWatch 来统计每个请求的执行时间: 虽然在firefox 中可以清楚的看到每个请求的执行时间,但是为了测试,记录日志, 方便以后查询维护. 还是必要的,下面 ...
- Hibernate操作Blob数据
首先看数据库.数据库中新建一个BlobTable表,表中有两个字段,一个id(主键)一个picture字段是Blob类型字段.然后使用Hibernate向该数据库中写入和读取数据 在POJO类中p ...
- C#串口通信发送数据
1 发送数据 需要2个串口 http://www.openedv.com/thread-228847-1-1.html 下载源文件 File_Protocol_Test.rar
- poj 2528(区间改动+离散化)
题意:有一个黑板上贴海报.给出每一个海报在黑板上的覆盖区间为l r,问最后多少个海报是可见的. 题解:由于l r取值到1e7,肯定是要离散化的,但普通的离散化会出问题.比方[1,10],[1,4],[ ...
- Lead软件项目半年感受
Lead一个项目快半年了,整体来说是个辛苦活. 除了自己的研发进度,还要负责对上,对下,对外的交流.这里记录一些感受. 对上的交流,除了确保正确理解老大的安排.就是确保老大在和他的lead以及 ...
- LeetCode 第 3 题(Longest Substring Without Repeating Characters)
LeetCode 第 3 题(Longest Substring Without Repeating Characters) Given a string, find the length of th ...
- JS中Float类型加减乘除 修复 JQ 操作 radio、checkbox 、select LINQ to SQL:Where、Select/Distinct LINQ to SQL Count/Sum/Min/Max/Avg Join
JS中Float类型加减乘除 修复 MXS&Vincene ─╄OvЁ &0000027─╄OvЁ MXS&Vincene MXS&Vincene ─╄Ov ...
- Oracle数据库字符集解释
转自:http://www.itpub.net/thread-836643-1-1.html Pl/SQL 执行select * from nls_database_parameters---可以查看 ...
- kubernetes对象之deployment
系列目录 简述 Deployment为Pod和ReplicaSet提供了一个声明式定义(declarative)方法,用来替代以前的ReplicationController来方便的管理应用.典型的应 ...
- SpringMVC学习(一):搭建SpringMVC-注解-非注解
文章参考:http://www.cnblogs.com/Sinte-Beuve/p/5730553.html 一.环境搭建: 目录结构: 引用的JAR包: 如果是Maven搭建的话pom.xml配置依 ...