Cod sursa(job #2594068)

Utilizator Katherine456719Swan Katherine Katherine456719 Data 5 aprilie 2020 13:13:36
Problema Algoritmul lui Euclid extins Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.72 kb
#include<iostream>
#include<fstream>
using namespace std;

inline int euclid_extins(int &x,int &y,int a,int b)
{
    if(b==0)
    {
        x = 1;
        y = 0;
        return a;
    }
    int x0,y0,D;
    D = euclid_extins(x0, y0, b, a % b);

    x = y0;
    y = x0 - y0 *(a / b);
    return D;
}
int main()
{
    ifstream cin("euclid3.in");
    ofstream cout("euclid3.in");
    int t;
    cin >> t;
    for(int i = 1; i <= t; i++)
    {

        int a,b,c;
        cin >> a >> b >> c;
        int x,y,d;
        d= euclid_extins(x,y,a,b);
        if(c%d)
            cout<< 0 << " " << 0 << "\n";
        else
            cout<< x * (c / d) << " " <<y * (c / d) <<"\n";
    }
    return 0;
}