Pagini recente » Cod sursa (job #2026220) | Cod sursa (job #838118) | Cod sursa (job #2902072) | Cod sursa (job #553554) | Cod sursa (job #3221466)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
long long t, a, b, c;
void euclid_extins(long long a, long long b, long long &x, long long &y) {
if (b==0) {
x=1, y=0;
}
else {
long long xx, yy;
euclid_extins(b, a%b, xx, yy);
x=yy;
y=xx-a/b*yy;
}
}
int main()
{
fin>>t;
while (t--) {
fin>>a>>b>>c;
if (c%__gcd(a, b)!=0) {
fout<<0<<' '<<0<<'\n';
continue;
}
long long x, y;
euclid_extins(a, b, x, y);
x*=c/__gcd(a, b);
y*=c/__gcd(a, b);
fout<<x<<' '<<y<<'\n';
}
return 0;
}