#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define sqr(x) ((x)*(x))
using namespace std;
const int M=;
const int N=;
int inv[M],mat[N][N];
void init(){//求逆元
inv[]=;
for(int i=;i<M;i++)
inv[i]=(M-M/i)*inv[M%i]%M;
}
int det(int c[][N],int n){//求矩阵c的n阶顺序主子式的绝对值
int i,j,k,w=,ans=;
for(i=;i<=n;i++)
for(j=;j<=n;j++) c[i][j]=(c[i][j]%M+M)%M;
for(i=;i<=n;i++){
for(j=i;j<=n;j++)//找出第i行起第i列不为0的行
if(c[i][j])break;
if(i!=j)
swap(c[i],c[j]);
ans=ans*c[i][i]%M;
for(j=i+;j<=n;j++)//第j行第i列变为0
for(k=n+;k>i;k--)//该行每列减去第i列的值*d
c[j][k]=(c[j][k]-c[i][k]*inv[c[i][i]]%M*c[j][i]%M+M)%M;
}
return ans;
}
struct point{
int x,y;
}p[N];
int same(point a,point b,point c){ //判断是否共线
return (a.x-c.x)*(b.y-c.y)==(b.x-c.x)*(a.y-c.y)
&&min(a.x,c.x)<=b.x&&max(a.x,c.x)>=b.x
&&min(a.y,c.y)<=b.y&&max(a.y,c.y)>=b.y;
}
int main(){
init();
int t,n,r;
scanf("%d",&t);
while(t--){
memset(mat,,sizeof mat);
scanf("%d%d",&n,&r);
for(int i=;i<=n;i++)
scanf("%d%d",&p[i].x,&p[i].y);
for(int i=;i<=n;i++)
for(int j=i+;j<=n;j++)
if(sqrt(sqr(p[i].x-p[j].x)+sqr(p[i].y-p[j].y))<=r){//距离不大于r
int ok=;
for(int k=;k<=n;k++)
if(k!=i&&k!=j&&same(p[i],p[k],p[j]))
ok=;
if(ok){//构造Kirchhoff矩阵
mat[i][j]=mat[j][i]=-;
mat[i][i]++;mat[j][j]++;
}
}
int ans=det(mat,n-);
printf("%d\n",ans?ans:-);
}
}

最新文章

  1. python 装饰器
  2. Viewbox在UWP开发中的应用
  3. ai seek
  4. 最全的iOS面试题及答案-转载
  5. 玩转cocos2d-x lua-binding, 实现c++与lua混合编程
  6. [under the hood]Reduce EXE and DLL Size with LIBCTINY.LIB
  7. P、NP、NPC、NP-Hard问题
  8. 【linux 命令】:查看系统开机,关机时间【转载】
  9. 代码里面执行bat
  10. carousel
  11. js判断是否微信浏览器打开
  12. 7. Reverse Integer
  13. 1.跨平台开发之~ VSCode开发第一个C程序
  14. 深入学习JS执行--创建执行上下文(变量对象,作用域链,this)
  15. 一文了解安卓APP逆向分析与保护机制
  16. Docker Data Center系列(二)- UCP安装指南
  17. pymongo 使用方法(增删改查)
  18. log4j日志输出框架
  19. iOS开发-应用管理
  20. testmath

热门文章

  1. 初识XXE漏洞
  2. Codeforces 540A - Combination Lock
  3. eclipse如何查看源码
  4. php实现自定义中间logo的微信小程序码
  5. Linux - mysql 异常: ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists
  6. layui table 超出自动换行
  7. PyQt5+Eric6开发的一个使用菜单栏、工具栏和状态栏的示例
  8. linux网卡
  9. 创建本地yum源仓库
  10. Java第一个程序HelloWorld