Pagini recente » Cod sursa (job #1790144) | Cod sursa (job #1546) | Cod sursa (job #1792829) | Cod sursa (job #2007281) | Cod sursa (job #2437944)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int t;
int gcd(int a,int b,int &x,int &y)
{
if(a==0)
{
x=0;
y=1;
return b;
}
int x1,y1;
int d=gcd(b%a,a,x1,y1);
y=x1;
x=y1-(b/a)*x1;
return d;
}
int main()
{
int a,b,c,d,x,y;
f>>t;
while(t--)
{
f>>a>>b>>c;
d=gcd(a,b,x,y);
if(c%d==0)
{
g<<x*(c/d)<<" "<<y*(c/d)<<"\n";
}
else
{
g<<0<<" "<<0<<"\n";
}
}
return 0;
}