首页 技术 正文
技术 2022年11月21日
0 收藏 348 点赞 3,426 浏览 1341 个字
 //一些点一些圆,过圆不能连线,相邻点不能连线,问最多连几条线
//计算几何模板+区间dp
//关键是判断圆和线段是否相交
#include <cstdio>
#include <cmath>
#include <algorithm>
#define N 500
#define ll long long
#define sqr(x) ((x)*(x))
using namespace std;
bool ok[N][N];
ll n,m,r,f[N][N];
struct poi
{
ll x,y;
poi(ll X,ll Y)
{
x=X;y=Y;
}
poi()
{
}
} p[N],q[N];
ll cro(poi a,poi b)
{
return (a.x*b.y-a.y*b.x);
}
ll dot(poi a,poi b)
{
return a.x*b.x+a.y*b.y;
}
poi tr(poi a,poi b)
{
return poi(a.x-b.x,a.y-b.y);
}
double dis(poi a,poi b)
{
return sqrt((double)(sqr(a.x-b.x)+sqr(a.y-b.y)));
}
bool cmp(poi a,poi b)
{
return (a.x<b.x)||(a.x==b.x && a.y<b.y);
}
bool cmp2(poi a,poi b)
{
return cro(tr(a,p[]),tr(b,p[]))>;
}
bool check(poi a,poi b)
{
double C=dis(a,b);
for(int i=;i<=m;i++)
{
double A=dis(q[i],a);
double B=dis(q[i],b);
double COSA=(B*B+C*C-A*A)/(*B*C);
double COSB=(A*A+C*C-B*B)/(*A*C);
if(COSA<1e-||COSB<1e-){
if(A<1.0*r+1e-||B<1.0*r+1e-)return ;
else continue;
}
double SINA=sqrt(-COSA*COSA);
double H=B*SINA;
if(H<1.0*r+1e-)return ;
}
return ;
}
int main()
{
scanf("%d%d%d",&n,&m,&r);
for(int i=;i<=n;i++)
scanf("%d%d",&p[i].x,&p[i].y);
sort(p+,p++n,cmp);
sort(p+,p++n,cmp2);
for(int i=;i<=m;i++)
scanf("%d%d",&q[i].x,&q[i].y);
for(int i=;i<=n;i++)
for(int j=i+;j<=n;j++)
if(i!= || j!=n)
ok[i][j]=check(p[i],p[j]);
for(int len=;len<=n;len++)
for(int start=;start<=n;start++){
ll end=start+len;
for(int k=start+;k<min(end,n);k++)
f[start][end]=max(f[start][end],f[start][k]+f[k][end]);
f[start][end]+=ok[start][end];
}
printf("%d\n",f[][n]);
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,956
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,480
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,327
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,110
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,741
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,776