首页 > 其他 > 详细

Hello World

时间:2019-01-13 11:29:02      阅读:80      评论:0      收藏:0      [点我收藏+]

标签:hello   opera   include   ons   world   turn   namespace   main   int   

#include <bits/stdc++.h>

using namespace std;

class point
{
public:
    int x, y, z;

    point(int x = 0, int y = 0, int z = 0): x(x), y(y), z(z)
    {
    }

    point operator - (const point &b) const
    {
        return point(x - b.x, y - b.y, z - b.z);
    }

    int operator * (const point &b) const
    {
        return x * b.x + y * b.y + z * b.z;
    }

    int sqr()
    {
        return *this * *this;
    }

    double len()
    {
        return sqrt(sqr());
    }
};

long long sqr(int x)
{
    return (long long) x * x;
}

int main()
{

    cout.setf(ios::fixed);
    cout.precision(10);
    int tt;
    cin >> tt;
    while (tt--)
    {
        point o, a, b;
        int r;
        cin >> o.x >> o.y >> o.z >> r;
        cin >> a.x >> a.y >> a.z;
        cin >> b.x >> b.y >> b.z;
        if ((a - b).sqr() == 0 || (o - a) * (b - a) <= 0 || (o - b) * (a - b) <= 0)
        {
            cout << (a - b).len() << "\n";
        }
        else
        {
            double h = sqrt((o - a).sqr() - (double) sqr((o - a) * (b - a)) / (a - b).sqr());
            if (r <= h)
            {
                cout << (a - b).len() << "\n";
            }
            else
            {
                double go_a = sqrt((o - a).sqr() - sqr(r));
                double go_b = sqrt((o - b).sqr() - sqr(r));
                double angle = atan2(sqrt((o - a).sqr() - h * h), h) + atan2(sqrt((o - b).sqr() - h * h), h) - atan2(go_a, r) - atan2(go_b, r);
                cout << angle * r + go_a + go_b << "\n";
            }
        }
    }
    return 0;
}

 

Hello World

标签:hello   opera   include   ons   world   turn   namespace   main   int   

原文:https://www.cnblogs.com/Agnel-Cynthia/p/10262101.html

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 bubuko.com 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号