Cod sursa(job #2502693)
| Utilizator | Data | 1 decembrie 2019 14:07:02 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.67 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
ll T, a, b, c;
ll gcd(ll a, ll b, ll& x, ll& y)
{
if(a == 0)
{
x = 0;
y = 1;
return b;
}
ll x1, y1;
ll d = gcd(b%a, a, x1, y1);
x = y1-(b/a)*x1;
y = x1;
return d;
}
int main()
{
fin >> T;
while(T--)
{
ll x_rez, y_rez;
fin >> a >> b >> c;
ll d = gcd(a, b, x_rez, y_rez);
if(c%d!=0)
fout << "0 0\n";
else
{
fout << x_rez*c/d << ' ' << y_rez*c/d << '\n';
}
}
return 0;
}
