Pagini recente » Cod sursa (job #1717717) | Cod sursa (job #239600) | Istoria paginii runda/biti2 | Statistici Rotar Mircea (rotti321) | Cod sursa (job #1292356)
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 1000003
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int T;
int euclidext(int a, int b, int &x, int &y)
{
if(b==0)
{
x = 1; y = 0;
return a;
}
else{
int cm = euclidext(b, a%b, x, y);
int aux = y;
y = x - y*(a/b);
x = aux;
return cm;
}
}
int main()
{
int a,b,c,d,x,y;
fin>>T;
for(int i=1;i<=T;i++)
{
fin>>a>>b>>c;
d=euclidext(a,b,x,y);
if(c%d==0)
fout<<c/d*x<<' '<<c/d*y<<'\n';
else
fout<<"0 0\n";
}
return 0;
}