Pagini recente » Cod sursa (job #2848345) | Cod sursa (job #2872220) | Cod sursa (job #2781052) | Cod sursa (job #2096072) | Cod sursa (job #1099162)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
long long a, b, c, x, y, t;
inline int cmmdc(int a,int b)
{
int r;
while(b!=0)
{
r=a%b;
a=b;
b=r;
}
return a;
}
inline void Euclid(long long a, long long b, long long &x, long long &y){
long long x0, y0;
if(!b) {x=1; y=0; return;}
else Euclid(b, a%b, x0, y0);
x=y0;
y=x0-y0*(a/b);
}
int main()
{
int N;
f>>N;
for(int i = 0 ; i < N; ++i)
{
f>>a>>b>>c;
int d = cmmdc(a,b);
if(c%d!=0)
{
g<<"0 0";
}
else
{
Euclid(a, b, x, y);
g<<x*c/d<<" "<<y*c/d<<endl;
}
}
return 0;
}