Cod sursa(job #2485079)

Utilizator theo2003Theodor Negrescu theo2003 Data 31 octombrie 2019 22:38:34
Problema Algoritmul lui Euclid extins Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.8 kb
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream in("euclid2.in");
ofstream out("euclid2.out");
long long int d;
long long int x, y;
void euclide(long long int a, long long int b) {
    cout<<"1";
    if (b == 0) {
        d = a;
        x = 1;
        y = 0;
    } else {
        euclide(b, a % b);
        long long int tmp = y;
        y = x - (a/b)*y;
        x = tmp;
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    long long int t;
    in>>t;
    while(t--) {
        cout<<"!";
        long long int a, b, c;
        in>>a>>b>>c;
        euclide(a, b);
        if(c % d){
            out<<"0 0\n";
            continue;
        }
        long long int tmp1 = c/d;
        out<<x*tmp1<<' '<<y*tmp1<<'\n';
    }
    return 0;
}