SP898 TRANSMIT - Transmitters

版权声明:喜欢请点个大拇指,感谢各位dalao。弱弱说下,转载要出处呦 https://blog.csdn.net/qq_35786326/article/details/85700069


题目:

传送门


分析:

在叉积的基础上加上暴力扫描~~
话说洛谷上好像还是紫题呦(好吧,其实我们团队炒作 逃:)


代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring> 
#include<cstdlib>
#include<algorithm>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<ctime>
#include<iomanip>
#include<string>
#include<bitset>
#include<deque>
#include<set>
#define LL long long
#define ch cheap
using namespace std;
inline LL read() {
    LL d=0,f=1;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
    return d*f;
}
int max(int x,int y){return x>y?x:y;}
int x[100005],y[100005];
int main()
{
    int x1,y1,m;double r;
    while(scanf("%d%d%lf",&x1,&y1,&r))
    {
        if(r<=0) break;
        int n=read();
        m=0;
        int a,b;
        for(int i=1;i<=n;i++)
        {
            a=read();b=read();
            if(sqrt((a-x1)*(a-x1)+(b-y1)*(b-y1))>r) continue;
            x[++m]=a;y[m]=b;
        }
        int ans=0;
        int l,r;
        for(int i=1;i<=m;i++)
        {
            l=0;r=0;
            for(int j=1;j<=m;j++)
            {
                int m=(x[i]-x1)*(y[j]-y1)-(x[j]-x1)*(y[i]-y1);
                if(m>0) r++;
                else l++; 
            }
            ans=max(ans,max(l,r));
        }
        printf("%d\n",ans);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_35786326/article/details/85700069