Pagini recente » Cod sursa (job #303319) | Cod sursa (job #1728742) | Cod sursa (job #2154454) | Cod sursa (job #1478619) | Cod sursa (job #2869384)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int a,b,c,d,x,y,t;
int cmmdc(int a, int b)
{
int r;
while(b)
{
r=a%b;
a=b;
b=r;
}
return a;
}
void euclid(int a, int b, int &d, int &x, int &y)
{
if(b==0)
{
d=a;
x=1;
y=0;
return;
}
int x0,y0;
euclid(b,a%b,d,x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
int main()
{
fin >> t;
while(t--)
{
fin >> a >> b >> c;
int d,x,y;
euclid(a,b,d,x,y);
if(c%d)
fout << "0 0\n";
else
fout << x*c/d << " " << y*c/d << '\n';
}
return 0;
}