Pagini recente » Monitorul de evaluare | Monitorul de evaluare | Cod sursa (job #3363393) | Monitorul de evaluare | Cod sursa (job #3362150)
#include <bits/stdc++.h>
#define int long long
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int euclid (int a, int b, int & x, int & y)
{
if (!b)
{
x=1, y=0;
return a;
}
int x1, y1;
int d=euclid (b, a%b, x1, y1);
x=y1;
y=x1-(a/b)*y1;
return d;
}
signed main ()
{
int t;
f >> t;
while (t--)
{
int a, b, c;
f >> a >> b >> c;
int x, y;
int d=euclid (a, b, x, y);
if (c%d)
g<<"0 0 \n";
else
g << x*(c/d) << ' ' << y*(c/d)<<'\n';
}
}