ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1489. Points on a Parallelepiped

Why I have WA#10?
Posted by Марьин 6 Oct 2024 21:40
Why I have WA#10? I can't think test to get wrong answer. PLS help me

Next my code:

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    double a, b, c, x, y, x2, y2;
    double X, Y, Z, X2, Y2, Z2;
    double result = 0;
    bool bflag = true;
    cin >> a >> b >> c;
    for (int i=0; i < 2; i++)
    {
        cin >> x >> y;
        if (x < c)
        {
            X = 0;
            Y = y - b - c;
            Z = x;
        }
        else if (x > c + a)
        {
            X = a;
            Y = y - b - c;
            Z = 2 * c + a - x;
        }
        else
        {
            if (y <= b)
            {
                X = x - c;
                Y = b - y;
                Z = 0;
            }
            else if (y <= b + c)
            {
                X = x - c;
                Y = 0;
                Z = y - b;
            }
            else if (y <= b)
            {
                X = x - c;
                Y = y - b - c;
                Z = c;
            }
            else
            {
                X = x - c;
                Y = b;
                Z = 2 * b + 2 * c - y;
            }
        }
        if (bflag)
        {
            x2 = x;
            y2 = y;
            X2 = X;
            Y2 = Y;
            Z2 = Z;
            bflag = false;
        }
    }
    //cout << X << ' ' << Y << ' ' << Z << ' ' << X2 << ' ' << Y2 << ' ' << Z2; это типа отладка
    X2 -= X;
    Y2 -= Y;
    Z2 -= Z;
    result = sqrt(X2 * X2 + Y2 * Y2 + Z2 * Z2);
    if (result < 1.E-8)
        cout << fixed << setprecision(6) << 0;
    else
        cout << fixed << setprecision(6) << result;

    return 0;
}
Re: Why I have WA#10?
Posted by Марьин 6 Oct 2024 21:48
Sorry, I'm find mistake now, it's a one wrong if in my code, thk all to find this