Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
3
Indexable
Never
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    double a, b, c, d, e, f,x,y,n,k;
    cin >> a >> b >> c >> d >> e >> f;
    
    if (a*d-b*c!=0)
    {
        x = (e * d - b * f) / (a * d - b * c);

        y = (a * f - e * c) / (a * d - b * c);

        cout << 2 << " " << x << " " << y;
    }
    else if ((e*d-b*f!=0)&&(a*f-e*c!=0))
    {
        cout << "0";
    }
    else if (a==0&&b==0&&c==0&&d==0)
    {
        if (e!=0||f != 0)
        {
            cout << "0";
        }
        else
        {
            cout << "5";
        }
    }
    else if (a==0&&c==0)
    {
        if (b != 0)
        {
            y = e / b;
            cout << "4 " << y;
        }
        else
        {
            y = f / d;
            cout << "4 " << y;
        }
    }
    else if (b==0&&d==0)
    {
        if (a != 0) {
            x = e / a;
            cout << "3 " << x;
        }
        else
        {
            x = f / c;
            cout << "3 " << x;
        }
    }
    else if (b!=0)
    {
        n = e / b;
        k = -a / b;
        cout << "1 " << k << " " << n;
    }
    else
    {
        n = f / d;
        k = -c / d;
        cout << "1 " << k << " " << n;
    }
    return 0;
}