Pagini recente » Cod sursa (job #2359314) | Cod sursa (job #2378208) | tema | Cod sursa (job #1026093) | Cod sursa (job #2945715)
#include <bits/stdc++.h>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
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()
{
int a,b,c,n;
in>>n;
while(n)
{
int x,y,d;
in>>a>>b>>c;
euclid(a,b,d,x,y);
if(c%d==0)
out<<x*(c/d)<<" "<<y*(c/d)<<'\n';
else
out<<'0 0'<<'\n';
n--;
}
return 0;
}