Pagini recente » Cod sursa (job #650538) | Cod sursa (job #548305) | Cod sursa (job #2821960) | Cod sursa (job #1184486) | Cod sursa (job #2211137)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
int n, a, b, x, y, c;
int cmmdc(int a, int b, int &x, int &y)
{
if(b==0)
{
x=1; y=0;
return a;
}
int ans = cmmdc(b, a%b, x, y);
int aux = x;
x = y;
y = aux - y*(a/b);
return ans;
}
int main()
{
in>>n;
for(int i=1; i<=n; i++)
{
in>>a>>b>>c;
int d = cmmdc(a, b, x, y);
if(c%d == 0)
out<<(c/d)*x<<' '<<(c/d)*y<<'\n';
else out<<"0 0"<<'\n';
}
return 0;
}