Pagini recente » Cod sursa (job #1759231) | Cod sursa (job #2549627) | Cod sursa (job #2194897) | Cod sursa (job #1460629) | Cod sursa (job #2310627)
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <algorithm>
#include <utility>
#include <type_traits>
#include <functional>
#include <cstdint>
#include <thread>
#include <limits>
#include <cassert>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <random>
#include <bitset>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <regex>
#include <future>
std::ofstream g{ "euclid3.out" };
void gcdext(int const t_a, int const t_b, int& t_res, int& t_x, int& t_y)
{
if(t_b == 0) {
t_res = t_a;
t_x = 1;
t_y = 0;
return;
}
int x0{ 0 }, y0{ 0 };
gcdext(t_b, t_a % t_b, t_res, x0, y0);
t_x = y0;
t_y = x0 - (t_a / t_b) * y0;
}
void read()
{
std::ifstream f{ "euclid3.in" };
int n, a, b, res;
f >> n;
for(int i = 0; i < n; ++i) {
f >> a >> b >> res;
int x, y, gcd;
gcdext(a, b, gcd, x, y);
if(res % gcd != 0) {
g << "0 0\n";
return;
}
g << x * (res / gcd) << ' ' << y * (res / gcd) << '\n';
}
}
int main()
{
read();
return 0;
}