Pagini recente » Cod sursa (job #2753418) | Cod sursa (job #1860040) | Cod sursa (job #3208850) | Cod sursa (job #1444982) | Cod sursa (job #2192914)
#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int x, y, a, b, c, d, T;
int gcd(int a, int b, int &x, int &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
int x0, y0, d=gcd(b, a%b, x0, y0);
x=y0;
y=x0-y0*(a/b);
return d;
}
int main()
{
f>>T;
while(T)
{
T--;
f>>a>>b>>c;
d=gcd(a,b,x,y);
if(c%d==0)
g<<x*(c/d)<<' '<<y*(c/d)<<'\n';
else
g<<"0 0\n";
}
return 0;
}