1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <cmath> 5 #define sqr(x) ((x)*(x)) 6 using namespace std; 7 const int M=10007; 8 const int N=301; 9 int inv[M],mat[N][N]; 10 void init(){//求逆元 11 inv[1]=1; 12 for(int i=2; I <M; I ++ ) 13 is INV [I] = (the MM / I) * INV [M% I]% M; 14 } 15 int DET ( int C [] [N], int n-) { // find matrix c n-th ordered sequence of master-type absolute value 16 int I, J, K, W = 0 , ANS = . 1 ; . 17 for (I = . 1 ; I <= n; I ++ ) 18 is for (J = . 1 ; J <= n-; J ++) C [I] [J] = (C [I] [J]% M + M)% M; . 19 for (I = . 1 ; I <= n-; I ++ ) { 20 is for (J = I; J <= n-; J ++) // find the i-th row from the first column is not 0 row i of 21 IF (C [I] [J]) BREAK ; 22 is IF (I =! J) 23 is the swap (C [I], C [J]); 24 ANS = ANS * C [I] [I]% M; 25 for (j = i + . 1 ; j <= n-; j ++) // j th row, i th column becomes 0 26 is for (n-K + = . 1 ; K> i; K--) // the row of each column is subtracted column D value i * 27 C [J] [K] = (C [J] [K] -C [i] [K] * INV [C [i] [i]] *% M C [J] [ I]% M + M)% M; 28 } 29 return ANS; 30 } 31 is struct Point { 32 int X, Y; 33 is }p[N]; 34 int same(point a,point b,point c){ //判断是否共线 35 return (a.x-c.x)*(b.y-c.y)==(b.x-c.x)*(a.y-c.y) 36 &&min(a.x,c.x)<=b.x&&max(a.x,c.x)>=b.x 37 &&min(a.y,c.y)<=b.y&&max(a.y,c.y)>=b.y; 38 } 39 int main(){ 40 init(); 41 int t,n,r; 42 scanf("%d",&t); 43 while(t--){ 44 memset(mat,0,sizeof mat); 45 scanf("%d%d",&n,&r); 46 for(int i=1;i<=n;i++) 47 scanf("%d%d",&p[i].x,&p[i].y); 48 for(int i=1;i<=n;i++) 49 for(int j=i+1;j<=n;j++) 50 if(sqrt(sqr(p[i].x-p[j].x)+sqr(p[i].y-p[j].y))<=r){//距离不大于r 51 int ok=1; 52 for(int k=1;k<=n;k++) 53 if(k!=i&&k!=j&&same(p[i],p[k],p[j])) 54 ok=0; 55 if(ok){//构造Kirchhoff矩阵 56 mat[i][j]=mat[j][i]=-1; 57 mat[i][i]++;mat[j][j]++; 58 } 59 } 60 int ans=det(mat,n-1); 61 printf("%d\n", years years: - 1 ); 62 } 63 }