QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#859300#9668. Isoball: 2D VersionyjtacCompile Error//C++144.5kb2025-01-17 17:12:002025-01-17 17:12:03

Judging History

你现在查看的是最新测评结果

  • [2025-01-17 17:12:03]
  • 评测
  • [2025-01-17 17:12:00]
  • 提交

answer

#include <iostream>
#include <math.h>
#include <numbers>

using namespace std;

long double PI = std::numbers::pi;

long double xo, yo, r, vx, vy, ix1, iy1, ix2, iy2;

struct place
{
    long double px;
    long double py;
};
/*
long double trans(place O, place A)
{
    long double tana = (A.py - O.py) / (A.px - O.px);
    if (A.px >= 0 && A.py >= 0)
    {
        return atan(tana);
    }
    else if (A.px < 0 && A.py <= 0)
    {
        return PI + atan(tana);
    }
    else if (A.px <= 0 && A.py >= 0)
    {
        return PI + atan(tana);
    }
    else if (A.px >= 0 && A.py <= 0)
    {
        return 2 * PI + atan(tana);
    }
    return atan(tana);
}*/

long double trans(place O, place A)
{
    double tana = (A.py - O.py) / (A.px - O.px);
    if (A.px - O.px >= 0 && A.py - O.py >= 0)
    {
        return atan(tana);
    }
    else if (A.px - O.px < 0 && A.py - O.py <= 0)
    {

        return PI + atan(tana);
    }
    else if (A.px - O.px <= 0 && A.py - O.py >= 0)
    {
        return PI +atan(tana);
    }
    else if (A.px - O.px >= 0 && A.py - O.py <= 0)
    {
        return 2 * PI + atan(tana);
    }
    return atan(tana);
}

int main()
{
    long int n;
    cin >> n;
    while (n--)
    {
        cin >> xo >> yo >> r >> vx >> vy >> ix1 >> iy1 >> ix2 >> iy2;
        swap(iy1, iy2);

        if (abs(ix1 - ix2) < 2 * r || abs(iy1 - iy2) < 2 * r)
        {
            cout << "No" << endl;
            continue;
        }

        long double L      = pow(vx * vx + vy * vy, 0.5);
        place       leftp  = {xo, yo};
        place       rightp = {xo + 3000000 * vx / L, yo + 3000000 * vy / L};

        long double t = trans(leftp, rightp) / PI;
        long double a = trans(leftp, {ix1 + r, iy1 - r}) / PI;
        long double b = trans(leftp, {ix1 + r, iy2 + r}) / PI;
        long double c = trans(leftp, {ix2 - r, iy1 - r}) / PI;
        long double d = trans(leftp, {ix2 - r, iy2 + r}) / PI;
        /*cout << t << endl;
        cout << a << endl;
        cout << b << endl;
        cout << c << endl;
        cout << d << endl;*/

        if (xo < ix1 + r)
        {
            if (yo > iy1 - r)
            {
                // cout << 1 << endl;
                if ((t >= 0 && t < b) || (t <= 2 && t > c))
                {
                    cout << "No" << endl;

                    continue;
                }
            }
            else if (yo < iy2 + r)
            {
                // cout << 2 << endl;
                if ((t > a && t <= 2) || (t < d && t >= 0))
                {
                    cout << "No" << endl;
                    continue;
                }
            }
            else
            {
                // cout << 3 << endl;
                if (t > a && t < b)
                {
                    cout << "No" << endl;
                    continue;
                }
            }
        }
        else if (xo > ix2 - r)
        {
            if (yo > iy1 - r)
            {
                 //cout << 4 << endl;
                if ((t > d && t <= 2) || (t < a && t >= 0))
                {
                    cout << "No" << endl;
                    continue;
                }
            }
            else if (yo < iy2 + r)
            {
                // cout << 5 << endl;
                if ((t > b && t <= 2) || (t < c && t >= 0))
                {
                    cout << "No" << endl;
                    continue;
                }
            }
            else
            {
                // cout << 6 << endl;
                if ((t > d && t <= 2) || (t < c && t >= 0))
                {
                    cout << "No" << endl;
                    continue;
                }
            }
        }
        else
        {
            if (yo > iy1 - r)
            {
                // cout << 7 << endl;
                if ((t > c && t <= 2) || (t < a && t >= 0))
                {
                    cout << "No" << endl;
                    //while(1);
                    continue;
                }
            }
            else if (yo < iy2 + r)
            {
                // cout << 8 << endl;
                if ((t > b && t <= 2) || (t < d && t >= 0))
                {
                    cout << "No" << endl;


                    continue;
                }
            } /*
             else
             { 
                 //cout << 9 << endl;
             }*/
        }

        cout << "Yes" << endl;
    }
    return 0;
}

Details

answer.code:7:23: error: ‘std::numbers’ has not been declared
    7 | long double PI = std::numbers::pi;
      |                       ^~~~~~~