Pagini recente » Cod sursa (job #183787) | Cod sursa (job #2256395) | Cod sursa (job #2437049) | Cod sursa (job #1532837) | Cod sursa (job #2950643)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <cstdio>
//#include <bits/stdc++.h>
#define fastio std :: ios_base :: sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
using namespace std;
/*struct order
{
int nod, cost;
bool operator < (const order &x) const
{
return cost > x.cost;
}
};
std::priority_queue <order> pq;
std::vector <int> v1(1030), v2(1030);
std::vector <int> :: iterator it;*/
int n, a, b, c;
inline int euclid(int a, int b, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int x0, y0, d;
d = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main(void)
{
//header ->
{
fastio
ios_base::sync_with_stdio(false);
cin.tie(NULL);
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
}
//input ->
{
cin >> n;
for(int i = 1; i <= n; i++)
{
cin >> a >> b >> c;
int d, x, y;
d = euclid(a, b, x, y);
if(c % d)
cout << 0 << ' ' << 0 << '\n';
else
cout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
}
//start of the program ->
{
}
//output ->
{
}
exit(0);
}