Pagini recente » Cod sursa (job #1256355) | Cod sursa (job #1720104) | Cod sursa (job #1838129) | Cod sursa (job #1229544) | Cod sursa (job #2428969)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void gcd(int a,int b,int *d,int *x,int *y)
{
if(b==0)
{
*d = a;
*x = 1;
*y = 0;
}
else
{
int x0,y0;
gcd(b,a%b,d,&x0,&y0);
*x = y0;
*y = x0 -(a/b)*y0;
}
}
int main()
{
int n,a,b,c,d,x,y;
fin>>n;
for(int i = 0;i<n;i++)
{
fin>>a>>b>>c;
gcd(a,b,&d,&x,&y);
if(c%d)
fout<<"0 0"<<endl;
else
fout<<x*(c/d)<<" "<<y*(c/d)<<endl;
}
return 0;
}