Cod sursa(job #2605876)

Utilizator KPP17Popescu Paul KPP17 Data 26 aprilie 2020 09:24:36
Problema Algoritmul lui Euclid extins Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#define fisier "ULTRA"
#include <fstream>
std::ifstream in(fisier ".in");
std::ofstream out(fisier ".out");


int main()
{
    int t; in >> t;

    while (t--)
    {
        int a, b, c, x, y; in >> a >> b >> c;
        bool swp = false;

        if (a < b)
        {
            std::swap(a, b);
            swp = true;
        }

        x = c / a;
        y = (c - x*a) / b;

        if (a % b != c - x*a - y*b)
            out << "0 0\n";
        else
        {
            x++;
            y -= a / b;

            if (swp)
                std::swap(x, y);

            out << x << ' ' << y << '\n';
        }
    }
}