Pagini recente » Cod sursa (job #233029) | Cod sursa (job #28278) | Cod sursa (job #1997392) | Cod sursa (job #821042) | Cod sursa (job #1099705)
#include <fstream>
#include <iostream>
#include <vector>
#include <bitset>
#include <string.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <deque>
using namespace std;
const char infile[] = "euclid3.in";
const char outfile[] = "euclid3.out";
ifstream fin(infile);
ofstream fout(outfile);
const int MAXN = 100005;
const int oo = 0x3f3f3f3f;
typedef vector<int> Graph[MAXN];
typedef vector<int> :: iterator It;
const inline int min(const int &a, const int &b) { if( a > b ) return b; return a; }
const inline int max(const int &a, const int &b) { if( a < b ) return b; return a; }
const inline void Get_min(int &a, const int b) { if( a > b ) a = b; }
const inline void Get_max(int &a, const int b) { if( a < b ) a = b; }
int gcd(int &a, int b, int &x, int &y) {
if(b == 0) {
x = 1;
y = 0;
return a;
}
int x0, y0, d;
d = gcd(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main() {
int T;
for(fin >> T ; T -- ; ) {
int a, b, c, x, y, d;
fin >> a >> b >> c;
d = gcd(a, b, x, y);
if(c % d)
fout << "0 0\n";
else
fout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
fin.close();
fout.close();
return 0;
}