标签:
3 3 2 -1 0 0 1 1 0 3 2 -1 0 0 0 1 0 3 1 -1 0 0 1 1 0
3 1 -1
/* *********************************************** Author :CKboss Created Time :2015年04月29日 星期三 08时23分56秒 File Name :HDOJ4305.cpp ************************************************ */ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <string> #include <cmath> #include <cstdlib> #include <vector> #include <queue> #include <set> #include <map> using namespace std; typedef long long int LL; const int maxn=500; const LL MOD=10007; int n,R; struct Point { int x,y; }pt[maxn]; int Dist(Point a,Point b) { return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); } LL a[maxn][maxn],b[maxn][maxn]; LL inv(LL a,LL m) { if(a==1) return 1; return inv(m%a,m)*(m-m/a)%m; } LL det(LL a[][maxn],int n) { for(int i=0;i<n;i++) for(int j=0;j<n;j++) b[i][j]=(a[i][j]+MOD)%MOD; int res=1; for(int i=0;i<n;i++) { for(int j=i;j<n;j++) { if(b[j][i]!=0) { for(int k=i;k<n;k++) swap(b[i][k],b[j][k]); if(i!=j) res=(MOD-res)%MOD; break; } } if(b[i][i]==0) { res=-1; break; } for(int j=i+1;j<n;j++) { LL mut=(b[j][i]*inv(b[i][i],MOD))%MOD; for(int k=i;k<n;k++) b[j][k]=(b[j][k]-(b[i][k]*mut)%MOD+MOD)%MOD; } res=(res*b[i][i])%MOD; } return res; } inline int Dot(Point a,Point b) { return a.x*b.x+a.y*b.y; } inline int Cross(Point a,Point b) { return a.x*b.y-a.y*b.x; } bool onSeg(Point p,Point a1,Point a2) { Point A=(Point){a1.x-p.x,a1.y-p.y}; Point B=(Point){a2.x-p.x,a2.y-p.y}; return Cross(A,B)==0&&Dot(A,B)<0; } int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int T_T; scanf("%d",&T_T); while(T_T--) { scanf("%d%d",&n,&R); for(int i=0;i<n;i++) { int x,y; scanf("%d%d",&x,&y); pt[i]=(Point){x,y}; } memset(a,0,sizeof(a)); for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { if(i==j) continue; if(Dist(pt[i],pt[j])<=R*R) { /// i--->j /// check bool flag=true; for(int k=0;k<n&&flag;k++) { if(k==j||k==i) continue; flag=!onSeg(pt[k],pt[i],pt[j]); } if(flag==false) continue; a[i][i]++; a[i][j]=-1; a[j][j]++; a[j][i]=-1; } } } LL ans=det(a,n-1); printf("%I64d\n",ans); } return 0; }
标签:
原文地址:http://blog.csdn.net/ck_boss/article/details/45362049