Pagini recente » Cod sursa (job #2176967) | Cod sursa (job #2114472) | Cod sursa (job #3159068) | Cod sursa (job #2470511) | Cod sursa (job #1825921)
#include <iostream>
#include <fstream>
using namespace std;
void euclid(int a, int b, int &d, int &x, int &y)
{
if(b==0)
{
d=a;
x=1;
y=0;
}
else
{
int x0, y0;
euclid(b,a%b,d,x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
}
int main()
{
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int a, b, r, x, y, d, t;
fin >> t;
while(t)
{
fin >> a >> b >> r;
euclid(a,b,d,x,y);
if(r%d) fout << "0 0";
else fout << x*(r/d) << " " << y*(r/d);
t--;
}
return 0;
}