Cod sursa(job #2909724)

Utilizator TheGarbageWeebIonescu Ioan-Andrei TheGarbageWeeb Data 14 iunie 2022 22:45:39
Problema Algoritmul lui Euclid extins Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.64 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
void euclid(int a, int b,int &d, int& x, int& y)
{
    if (b == 0)
    {
        d = a;
        x = 1, y = 0;
    }
    else
    {
        int x1, y1;
        euclid(b, a % b, d,x1, y1);
        x = y1;
        y = x1 - a / b * y1;
    }
}

int main()
{
    int n, a, b, c,d,x=-0,y=0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
    cin >> a >> b >> c;
    euclid(a, b, d, x, y);
    if (c % d)
        cout << "0 0" << endl;
    else
        cout << x * c / d << " " << y * (c / d)<<endl;
}
}