Pagini recente » Cod sursa (job #2480530) | Cod sursa (job #1378589) | Cod sursa (job #1640465) | Cod sursa (job #1643943) | Cod sursa (job #2848050)
#include <bits/stdc++.h>
#define NMAX 260
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
long long int d, x, y, i,n, m, a, b, c;
void euclid(long long int a, long long int b, long long int& d, long long int&x, long long int&y){
if(b==0)
{
d=a;
x=1;
y=0;
}
else
{
long long int x0, y0;
euclid(b, a%b, d, x0, y0);
x=y0;
y=x0-(a/b)*y0;
}
}
int main()
{
fin >> n;
for(i=0; i<n; i++)
{
fin >> a >> b >> c;
euclid(a, b, d, x, y);
if(c%d!=0)
{
fout << 0 << ' ' << 0 << '\n';
}
else
{
fout << x*(c/d) << ' ' << y*(c/d) << '\n';
}
d=0;
x=0;
y=0;
}
return 0;
}