Pagini recente » Cod sursa (job #1876044) | Cod sursa (job #1803487) | Cod sursa (job #2953934) | Cod sursa (job #462000) | Cod sursa (job #3164791)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
#define MAX 2000000000
#define MIN -2000000000
long long r,a,b,c,x,y,n,d;
void euclid(long long a, long long b, long long &x, long long &y)
{
if (b==0)
{
x=1;
y=0;
}
else
{
long long x0,y0;
euclid(b,a%b,x0,y0);
x=y0;
y=x0-y0*(a/b);
}
}
int main()
{
fin >> n;
for (int i=1; i<=n; i++)
{
fin >> a >> b >> c;
euclid(a,b,x,y);
d=a*x+b*y;
if (x>MAX || x<MIN || y>MAX || y<MIN)
fout << 0 << " " << 0 << '\n';
else
{
if (c%d!=0)
fout << 0 << " " << 0 << '\n';
else
{
r=c/d;
x*=r;
y*=r;
if (x>MAX || x<MIN || y>MAX || y<MIN)
fout << 0 << " " << 0 << '\n';
else
fout << x << " " << y << '\n';
}
}
}
return 0;
}