Pagini recente » Rating Dorinel Alex (boss_nr_ek) | Cod sursa (job #3218958) | Cod sursa (job #1542576) | Cod sursa (job #1021875) | Cod sursa (job #1316238)
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define MOD 1999999973
int euclid(int a, int b, int &x, int &y){
if(b==0){
x = 1; y = 0;
return a;
}
int d, aux;
d = euclid(b, a%b, x, y);
aux = x;
x = y;
y = aux - y*(a/b);
return d;
}
int main()
{
int t, x, y;
fin>>t;
for(int i=1;i<=t;i++)
{
int a, b, c, d;
fin>>a>>b>>c;
d=euclid(a, b, x, y);
if(c%d==0)
fout<<x*(c/d)<<" "<<y*(c/d)<<'\n';
else
fout<<"0 0\n";
}
return 0;
}