Pagini recente » Cod sursa (job #1780318) | Cod sursa (job #1533296) | Cod sursa (job #2942277) | Cod sursa (job #1351635) | Cod sursa (job #2575983)
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int t, a, b, c, cmmdc, x, y;
void euclid (int a, int b, int &k, int &l)
{
if(b==0)
{
k=1;
cmmdc=a;
l=0;
return;
}
int kp, lp;
euclid(b,a%b,kp,lp);
k=lp;
l=kp-lp*(a/b);
}
int main()
{
f >> t;
for (int test=1; test<=t; ++test)
{
f >> a >> b >> c;
euclid(a,b,x,y);
if (c%cmmdc)
g << 0 <<' ' << 0 << '\n';
else
{
x=x*(c/cmmdc);
y=y*(c/cmmdc);
g << x <<' ' << y << '\n';
}
}
return 0;
}