CF33D Knights

 

>>>圆 不相交

》》》 可能在同一个 圆形

 

——整形运算 快于 double

—— 强制转换 ans=(double) int/int -> double     or  int  因为double也可以有整数

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#define ll long long
#define ddd printf("-----------------debug\n");
using namespace std;
const int maxn=100000 ;

ll n,m,k,ans=0;

struct circle{
    ll x,y,r;
}c[10010];
struct point{
    ll x,y;
}p[10010];

bool in(ll a,ll b,ll x,ll y,ll r){
    return (a-x)*(a-x)+(b-y)*(b-y)<=r*r;//
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++) cin>>p[i].x>>p[i].y;
    for(int i=1;i<=m;i++) cin>>c[i].r>>c[i].x>>c[i].y;
    
    for(int i=1;i<=k;i++)
    {
        ans=0;
        int s,t; cin>>s>>t;
        
        for(int j=1;j<=m;j++)
        {
            ans+=in(p[s].x,p[s].y,c[j].x,c[j].y,c[j].r)^in(p[t].x,p[t].y,c[j].x,c[j].y,c[j].r);
        }
        cout<<ans<<'\n';
    }
    
    /*
    int xx=10,yy=4;
    double ss=(double)xx/yy;
    cout<<ss<<endl;
    */
    return 0;
}
View Code

 

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#define ll long long
#define ddd printf("-----------------debug\n");
using namespace std;
const int maxn=100000 ;

ll n,m,k,ans=0;

struct circle{
    ll x,y,r;
}c[10010];
struct point{
    ll x,y;
}p[10010];

int in(ll a,ll b,ll x,ll y,ll r){
    return 1.0*(a-x)*(a-x)+1.0*(b-y)*(b-y)<=1.0*r*r;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++) cin>>p[i].x>>p[i].y;
    for(int i=1;i<=m;i++) cin>>c[i].r>>c[i].x>>c[i].y;
    
    for(int i=1;i<=k;i++)
    {
        ans=0;
        int s,t; cin>>s>>t;
        
        for(int j=1;j<=m;j++)
        {
            ans+=in(p[s].x,p[s].y,c[j].x,c[j].y,c[j].r)^in(p[t].x,p[t].y,c[j].x,c[j].y,c[j].r);
        }
        cout<<ans<<'\n';
    }
    retu
 
posted @ 2023-08-04 17:20  JMXZ  阅读(11)  评论(0)    收藏  举报