Pagini recente » Cod sursa (job #2155045) | Cod sursa (job #1182583) | Cod sursa (job #2173848) | Cod sursa (job #1899929) | Cod sursa (job #2860619)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t, d;
void euclid(int a, int b, int &x, int &y){
if(b == 0){
d = a;
x = 1;
y = 0;
}
else{
int x0, y0;
euclid(b, a%b, x0, y0);
x = y0;
y = x0-(a/b)*y0;
}
}
int main()
{
fin >> t;
for(int i=1; i<=t; i++){
int a, b, c, x, y;
fin >> a >> b >> c;
euclid(a, b, x, y);
// fout << x << ' ' << y << '\n';
if(c % d != 0){
x = 0;
y = 0;
}
else{
x *= c/d;
y *= c/d;
}
//fout << d << '\n';
fout << x << ' ' << y << '\n';
}
return 0;
}