Pagini recente » Cod sursa (job #1882205) | Cod sursa (job #1826288) | Cod sursa (job #2794629) | Cod sursa (job #2942749) | Cod sursa (job #2817499)
#include <bits/stdc++.h>
#define n_max 100001
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int n;
int euclid(int a, int b, int &x, int &y)
{
if(!b)
{
x = 1;
y = 0;
return a;
}
int x0, y0;
int cmmdc = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - y0 * (a / b);
return cmmdc;
}
void solve(int a, int b, int c)
{
int x, y;
int cmmdc = euclid(a, b, x, y);
if(c % cmmdc)
g<<0<<" "<<0<<'\n';
else
g<<x * (c / cmmdc)<<" "<<y * (c / cmmdc)<<'\n';
}
void read()
{
f>>n;
int a, b, c;
for(int i = 1;i <= n;++i)
{
f>>a>>b>>c;
solve(a, b, c);
}
}
int main()
{
read();
return 0;
}