Pagini recente » Cod sursa (job #3223156) | Cod sursa (job #1641287) | Cod sursa (job #225590) | Cod sursa (job #609608) | Cod sursa (job #2772907)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
void usain_bolt()
{
ios::sync_with_stdio(false);
fin.tie(0);
}
int ext_euclid(int a, int b, int &x, int &y)
{
if(b == 0) {
x = 1;
y = 0;
return a;
}
else {
int x1, y1;
int g = ext_euclid(b, a % b, x1, y1);
x = y1;
y = x1 - a / b * y1;
return g;
}
}
int main()
{
usain_bolt();
int tt;
fin >> tt;
for(; tt; --tt) {
int x, y, z, a, b, c;
fin >> a >> b >> c;
int ans = ext_euclid(a, b, x, y);
if(c % ans == 0) {
fout << c / ans * x << " " << c / ans * y << "\n";
}
else {
fout << "0 0\n";
}
}
return 0;
}