Pagini recente » Cod sursa (job #586066) | Cod sursa (job #120811) | Cod sursa (job #3321463) | Cod sursa (job #944109) | Cod sursa (job #3323069)
//https://www.infoarena.ro/problema/euclid3
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("fast-math")
//#pragma GCC optimize ("unroll-loops")
//#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
//#include <vector>
//#include <cstring>
//#include <cmath>
//#include <bitset>
//#include <queue>
//#include <stack>
//#include <utility>
//#include <algorithm>
//#include <string>
//#include <map>
//#include <unordered_map>
//#include <set>
//#include <unordered_set>
//#include <cstdint>
//#include <climits>
//#include <iomanip>
//#include <cstdio>
//#include <tuple>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(int a, int b, int& c, int& x, int& y)
{
if (b == 0)
{
c = a;
x = 1;
y = 0;
}
else
{
int x0, y0;
euclid(b, a % b, c, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
//ios_base::sync_with_stdio(false);
//cin.tie(nullptr);
//cout.tie(nullptr);
int t;
fin >> t;
for (int i = 1; i <= t; ++i)
{
int a, b, c;
fin >> a >> b >> c;
int x, y, d;
euclid(a, b, d, x, y);
if (c % d == 0)
fout << x * c / d << " " << y * c / d << "\n";
else
fout << "0 0\n";
}
return 0;
}