题目链接:

Eureka

Time Limit: 8000/4000 MS (Java/Others)  

  Memory Limit: 65536/65536 K (Java/Others)

Problem Description
 
Professor Zhang draws n points on the plane, which are conveniently labeled by 1,2,...,n. The i-th point is at (xi,yi). Professor Zhang wants to know the number of best sets. As the value could be very large, print it modulo 109+7.

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.

 
Input
 
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:

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.

 
Output
 
For each test case, output an integer denoting the answer.
 
Sample Input
 
3
3
1 1
1 1
1 1
3
0 0
0 1
1 0
1
0 0
 
Sample Output
 
4
3
0
 
题意:
 
给 n个点,大于等于2个在同一条直线上的点可以构成一个集合,问你现在有多少个集合;
 
思路:
 
先把给的这些点按坐标排序,然后按顺序选一个点i,这个点i作为一定选到集合里面的点,然后再选枚举这个点之后的点j,形成一条直线,再看这条直线上没有被访问过的点k(i<k<n&&k!=j)有多少;假设有num个,那么就可以形成包含点i的集合2^num-1,同时这些点里面有重合的点,还有就是为降低复杂度,要用极角排序,但是最后判断的时候极角排序的精度好像又不太够,所有我就直接用原来的坐标判断的;
 
AC代码:
#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(组合计数+极角排序)的更多相关文章

  1. HDU 5738 Eureka(极角排序)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5738 [题目大意] 给出平面中一些点,在同一直线的点可以划分为一个集合,问可以组成多少包含元素不少 ...

  2. hdu 5738 Eureka 极角排序+组合数学

    Eureka Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  3. HDU 5738 Eureka 统计共线的子集个数

    Eureka 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5738 Description Professor Zhang draws n poin ...

  4. HDU 5738 Eureka

    传送门 题目大意: 给出平面上的$n$个点,每个点有唯一的标号($\text{label}$),这$n$个标号的集合记作$S$,点可能重合.求满足下列条件的$S$的子集$T$的数目: 1. $|T|\ ...

  5. 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 ...

  6. LA 4064 (计数 极角排序) Magnetic Train Tracks

    这个题和UVa11529很相似. 枚举一个中心点,然后按极角排序,统计以这个点为钝角的三角形的个数,然后用C(n, 3)减去就是答案. 另外遇到直角三角形的情况很是蛋疼,可以用一个eps,不嫌麻烦的话 ...

  7. hdu 3908 Triple(组合计数、容斥原理)

    Triple Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others) Total Su ...

  8. [CF1025F]Disjoint Triangles[极角排序+组合计数]

    题意 平面上有 \(n\) 个点,选出六个点构成两个三角形,问有多少种构造方式使得两个三角形没有交集. \(n\leq 2000\) 分析 枚举连接两个三角形的两个顶点,同时能够将两个三角形划分在直线 ...

  9. 【极角排序+双指针线性扫】2017多校训练七 HDU 6127 Hard challenge

    acm.hdu.edu.cn/showproblem.php?pid=6127 [题意] 给定平面直角坐标系中的n个点,这n个点每个点都有一个点权 这n个点两两可以连乘一条线段,定义每条线段的权值为线 ...

随机推荐

  1. sdut 面向对象程序设计上机练习九(对象指针)

    面向对象程序设计上机练习九(对象指针) Time Limit: 1000MS Memory limit: 65536K 题目描写叙述 建立对象数组,内放5个学生数据(学号是字符串类型.成绩是整型).设 ...

  2. 配置mysql主从服务器

    参考:https://www.linuxidc.com/Linux/2016-09/135633.htm 一.Master主服务器配置(192.168.1.3) 1.编辑my.cnf(命令查找文件位置 ...

  3. <转>关于 error LNK2019:无法解析的外部符号 ,该符号在函数**中被引用的思考

    错误提示信息摘抄如下: ---------------------------------------------------------------------------------------- ...

  4. 后台运行命令:&amp;和nohup command &amp; 以及关闭、查看后台任务

    当我们在终端或控制台工作时.可能不希望由于执行一个作业而占住了屏幕,由于可能还有更重要的事情要做,比方阅读电子邮件. 对于密集訪问磁盘的进程,我们更希望它可以在每天的非负荷高峰时间段执行(比如凌晨). ...

  5. 使用Python与数据库交互

    # -*- coding: utf-8 -*- """ Created on Sun Nov 18 19:25:01 2018 @author: wangm " ...

  6. 详谈kubernetes更新-2

    系列目录 本文详细探索deployment在滚动更新时候的行为 要详细探讨的参数描述: livenessProbe:存活性探测.判断pod是否已经停止 readinessProbe:就绪性探测.判断p ...

  7. 【机器学习算法-python实现】PCA 主成分分析、降维

    1.背景         PCA(Principal Component Analysis),PAC的作用主要是减少数据集的维度,然后挑选出基本的特征.         PCA的主要思想是移动坐标轴, ...

  8. adb tcp 调试

    su setprop service.adb.tcp.port 5555 stop adbd start adbd

  9. Arrays.sort(a) 自定义排序

     Arrays.sort(a) 自定义排序,(需实现接口:Comparable) package com.hd; import java.util.Arrays; class Person imple ...

  10. 在Mac OS中配置CMake的详细图文教程http://blog.csdn.net/baimafujinji/article/details/78588488

    CMake是一个比make更高级的跨平台的安装.编译.配置工具,可以用简单的语句来描述所有平台的安装(编译过程).并根据不同平台.不同的编译器,生成相应的Makefile或者project文件.本文主 ...