Cod sursa(job #3292365)
Utilizator | Data | 8 aprilie 2025 10:07:15 | |
---|---|---|---|
Problema | Algoritmul lui Euclid extins | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.65 kb |
#include <bits/stdc++.h>
#define int long long
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int Q, a, b, c, x, y, d;
void Euclid(int a, int b, int &d, int &x, int &y){
if(b == 0)
x = 1, y = 0, d = a;
else {
int x1, y1;
Euclid(b, a % b, d, x1, y1);
x = y1;
y = x1 - a / b * y1;
}
}
int32_t main(){
fin >> Q;
while(Q--){
fin >> a >> b >> c;
Euclid(a, b, d, x, y);
if(c % d != 0)
fout << "0 0\n";
else fout << (a * c) / d << " " << (b * c) / d << "\n";
}
}