题解

4 条题解

  • 0
    @ 2018-04-24 16:35:59

    总之就是纯模拟就好了,要记录该点有没有被选

    #include<iostream>
    using namespace std;
    struct node{
        double x,y,z;
        int pan,w;
    }q[1010];
    int main()
    {
        int n,m,sum=0,i,j;
        double l,r,a,b,c,dep;
        cin>>n>>m>>l>>r;
        l=l*l;
        r=r*r;
        for(i=1;i<=n;i++)
        {
            cin>>q[i].x>>q[i].y>>q[i].z>>q[i].w;
            q[i].pan=0;
        }
        for(i=1;i<=m;i++)
        {
            cin>>a>>b>>c;
            for(j=1;j<=n;j++)
            {
                if(q[j].pan)
                 continue;
                dep=(q[j].x-a)*(q[j].x-a)+(q[j].y-b)*(q[j].y-b)+(q[j].z-c)*(q[j].z-c);
                if(dep>l-10e-9&&dep<r+10e-9)
                 {
                    sum+=q[j].w;
                    q[j].pan=1;
                 }
            }
        }
        cout<<sum;
        return 0;
    }
    
  • 0
    @ 2016-03-23 16:52:16

    第9个提交的银,正确率没掉100%

  • 0
    @ 2015-11-06 23:43:49
    #include <cstdio>
    #include <algorithm>
    #include <cmath>
    using namespace std;
    const int MAXN = 1000 + 5;
    
    struct Pt {
        float x{}, y{}, z{};
        int ene{} {};
        bool vis;
    
        Pt() {
            vis = false;
        }
    
    } pt[MAXN];
    
    float calc(Pt a, Pt b) {
        float dx, dy, dz;
        dx = a.x - b.x;
        dy = a.y - b.y;
        dz = a.z - b.z;
        return sqrt(dx * dx + dy * dy + dz * dz);
    }
    
    int main() {
        int n, m, ans = 0;
        float l, r;
        scanf("%d%d%f%f", &n, &m, &l, &r);
        for (int i = 1; i <= n; ++i) {
            scanf("%f%f%f%d", &pt[i].x, &pt[i].y, &pt[i].z, &pt[i].ene);
        }
        for (int i = 1; i <= m; ++i) {
            Pt p;
            scanf("%f%f%f", &p.x, &p.y, &p.z);
            for (int j = 1; j <= n; ++j) {
                float dis = calc(p, pt[j]);
                if (dis >= l && dis <= r && !pt[j].vis) {
                    ans += pt[j].ene;
                    pt[j].vis = true;
                }
            }
        }
        printf("%d\n", ans);
        return 0;
    }
    
  • 0
    @ 2015-11-04 15:16:24

    直接模拟就好了

  • 1

信息

ID
1968
难度
3
分类
(无)
标签
递交数
49
已通过
25
通过率
51%
被复制
3
上传者