目录
前言:菜狗一枚,暴力解的,就想记录一下自己打比赛时怎么写的。
1、题目描述
2、代码:
#include<iostream>
#include<cmath>
using namespace std;
typedef long long LL;
struct Node{
LL x;
LL y;
LL r;
};
int ans=0;
void count();
int N,M;
const int nn =5*1e4+1;
Node zlei[nn];
Node plei[nn];
int main()
{
cin>>N>>M;
//Node zlei[N+1];
//Node plei[M+1];
for(int i=1;i<=N;i++)
{
LL xx,yy,rr;
cin>>xx>>yy>>rr;
zlei[i].x = xx;zlei[i].y = yy;zlei[i].r = rr;
}
for(int i=1;i<=M;i++)
{
LL xx,yy,rr;
cin>>xx>>yy>>rr;
plei[i].x = xx;plei[i].y = yy;plei[i].r = rr;
}
count();
cout<<ans<<endl;
return 0;
}
void judge(int j)
{
for(int i=1;i<=N;i++)
{
if(i==j)continue;
LL d = ((pow((zlei[i].x-zlei[j].x),2) + pow((zlei[i].y-zlei[j].y),2)));
LL d2 = pow(zlei[j].r,2);
if(d<=d2&&zlei[j].r!=0)
{
ans++;
zlei[i].r = 0;
}
}
}
void count()
{
for(int i=1;i<=M;i++)
{
for(int j=1;j<=N;j++) //i表示第几个排雷火箭,j第几个炸弹
{
LL d = ((pow((plei[i].x-zlei[j].x),2) + pow((plei[i].y-zlei[j].y),2)));
LL d2 = pow(plei[i].r,2);
if(d<=d2&&zlei[j].r!=0)
{
ans++;
judge(j);
zlei[j].r = 0;
}
}
}
}
总结:这是第二次参赛,估计也是大学最后一次参加蓝桥杯了,写了六道题,很多还是用暴力解,刷的题还是太少,这一年几乎没什么大的进步,菜就得挨打,真是去送钱了,人菜进不了决赛只能怪自己了,继续加油吧!骚年。。。。