HDU 5738 Eureka(map瞎搞)
来源:互联网 发布:如何成为一个网络作家 编辑:程序博客网 时间:2024/06/05 11:04
http://acm.hdu.edu.cn/showproblem.php?pid=5738
题意:让你求集合的数量,在这个集合里有一对点,然后其余所有点,都在这两点的线段上。
–
题解:总的来说就是求共线问题,为了不重复计算,我们枚举i的时候,只考虑从i+1到n的点,考虑共线,就要进行极角排序,但是可能会有精度误差,如果用double的话,就会GG,所以我选择了map存
代码:
#include <map>#include <set>#include <stack>#include <queue>#include <cmath>#include <string>#include <vector>#include <cstdio>#include <cctype>#include <cstring>#include <sstream>#include <cstdlib>#include <iostream>#include <algorithm>#pragma comment(linker,"/STACK:102400000,102400000")using namespace std;#define MAX 1005#define MAXN 1000005#define maxnode 15#define sigma_size 30#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define lrt rt<<1#define rrt rt<<1|1#define middle int m=(r+l)>>1#define LL long long#define ull unsigned long long#define mem(x,v) memset(x,v,sizeof(x))#define lowbit(x) (x&-x)#define pii pair<int,int>#define bits(a) __builtin_popcount(a)#define mk make_pair#define limit 10000//const int prime = 999983;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f;const double pi = acos(-1.0);const double inf = 1e18;const double eps = 1e-8;const LL mod = 1e9+7;const ull mx = 133333331;/*****************************************************/inline void RI(int &x) { char c; while((c=getchar())<'0' || c>'9'); x=c-'0'; while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0'; }/*****************************************************/int x[MAX],y[MAX];struct PP{ int x,y;}u;map<pii,int> ma;struct Node{ LL dis; int x,y; bool operator < (const Node&a)const{ return dis<a.dis; }}p[MAX];LL fact[1005];void init(){ fact[0]=1; for(int i=1;i<=1000;i++) fact[i]=fact[i-1]*2%mod;}int gcd(int a,int b){ if(!b) return a; return gcd(b,a%b);}int main(){ //freopen("in.txt","r",stdin); int t; cin>>t; //cout<<fabs(atan2(2,1)-atan2(-2,-1))<<endl; init(); while(t--){ int n; cin>>n; for(int i=0;i<n;i++){ scanf("%d%d",&x[i],&y[i]); //x[i]=y[i]=0; } LL ans=0; for(int i=0;i<n;i++){ int tot=0; int num=0; for(int j=i+1;j<n;j++){ //if(i==j) continue; if(x[i]==x[j]&&y[i]==y[j]){ num++; continue; } int flag=1; if(x[j]-x[i]<0||(x[j]-x[i]==0&&y[j]-y[i]<0)) flag=-1; p[tot++]=(Node){((LL)x[j]-x[i])*((LL)x[j]-x[i])+((LL)y[j]-y[i])*((LL)y[j]-y[i]),(x[j]-x[i])*flag,(y[j]-y[i])*flag}; } sort(p,p+tot); ma.clear(); for(int j=0;j<tot;j++){ int k=gcd(abs(p[j].x),abs(p[j].y)); ans+=fact[ma[mk(p[j].x/k,p[j].y/k)]+num]; ma[mk(p[j].x/k,p[j].y/k)]++; if(ans>=mod) ans-=mod; } ans+=((fact[num]-1+mod)%mod); if(ans>=mod) ans-=mod; } cout<<ans<<endl; } return 0;}
0 0
- HDU 5738 Eureka(map瞎搞)
- 【hdu 5738】Eureka
- HDU 5738 Eureka
- HDU 5738 Eureka
- HDU 5738 Eureka
- [HDU 5738] Eureka (计数)
- HDU 5738 Eureka(计数)
- 【瞎搞】 HDU 1986 Encoding
- 【瞎搞】HDU 5124 lines
- 【瞎搞】 HDU 5312 Sequence
- hdu 5738 Eureka 极角排序 计数
- hdu 5738 Eureka(组合数)
- hdu 5738 多校2 Eureka 【几何计数】
- hdu 5738 Eureka 极角排序
- HDU 5738 Eureka(组合数学)
- HDU 5738 Eureka(统计共线点对)
- HDU 2478 Slides(瞎搞,预处理)
- HDU 4925 Apple Tree (瞎搞)
- UVa 10935 Throwing cards away I(习题5-3)
- Codeforces #364(Div.2)C.They Are Everywhere【思维】
- CodeForces 699D—— Fix a Tree(并查集判断环)
- Android Service 学习总结 1
- iOS开发UI篇—程序启动原理和UIApplication
- HDU 5738 Eureka(map瞎搞)
- B - B
- Android性能调优利器StrictMode
- 模拟常见的字符操作函数
- 类的派生性
- http://blog.csdn.net/mindfloating/article/details/51534289
- 学习java day01
- iOS - 小文件下载篇(下载完写入文件)
- Codeforces 364Div2