Cod sursa(job #3356718)

Utilizator Car13Carmi Carabas Car13 Data 3 iunie 2026 17:36:30
Problema Algoritmul lui Euclid extins Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.94 kb
#include <iostream>
#include <fstream>

using namespace std;

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

int main(){
    long long y0 = 0, y1 = 1;
    long long x0 = 1, x1 = 0;
    long long a, b, c, d;
    long long r, q, y, x;
    int t;
    fin >> t;
    for(int i = 0; i < t; i++){
        fin >> a >> b >> c;
        while (b != 0)
        {
            r = a % b;
            q = a / b;
            a = b;
            b = r;
            x = x0 - q * x1;
            y = y0 - q * y1;
            y0 = y1; x0 = x1;
            y1 = y; x1 = x;
            cout << a << " " << b << " ";
            cout << q << " " << r << " ";
            cout << y1 << " " << y0 << endl;
        }
        d = a;
        if(c % d == 0){
            fout << x0  << " " << y0<< endl;
        }
        else{
            fout << 0 << " " << 0 << endl;
        }
    }
    fin.close();
    fout.close();
    return 0;
}