Cod sursa(job #2919592)

Utilizator PetrescuAlexandru Petrescu Petrescu Data 18 august 2022 12:33:13
Problema Algoritmul lui Euclid extins Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.69 kb
#include <bits/stdc++.h>

using namespace std;

void solve(int a, int b, int c, int &x, int &y) {
    if(b == 0) {
        if(c % a)
            return;

        x = c / a;
        y = 23;
        return;
    }

    solve(b, a % b, c, x, y);

    int cat = a / b;
    int x1 = x, y1 = y;

    x = y1;
    y = x1 - y1 * cat;
}

int main()
{
    ifstream fin("euclid3.in");
    ofstream fout("euclid3.out");

    int t;

    fin >> t;

    for(int test = 0; test < t; test++) {
        int a, b, c;

        fin >> a >> b >> c;

        int x, y;
        x = y = 0;

        solve(a, b, c, x, y);

        fout << x << " " << y << '\n';
    }

    return 0;
}