Pagini recente » Cod sursa (job #2756351) | Cod sursa (job #156807) | Cod sursa (job #2930920) | Cod sursa (job #2984347) | Cod sursa (job #2131598)
#include <iostream>
#include <fstream>
#include <vector>
#include <bits/stdc++.h>
#include <algorithm>
std::ifstream in("euclid3.in");
std::ofstream out("euclid3.out");
void euclid(int a, int b, int *d, int *x, int *y)
{
if (b == 0) {
*d = a;
*x = 1;
*y = 0;
} else {
int x0, y0;
euclid(b, a % b, d, &x0, &y0);
*x = y0;
*y = x0 - (a / b) * y0;
}
}
int main()
{
int t;
in >> t;
int a,b,c,d,x,y;
for(int i = 0 ; i < t ; i++)
{
in >> a >> b >> c;
euclid(a,b,&d,&x,&y);
if(c%d!=0)
out<<" 0 0\n";
else
{
x = x*c/d;
y= t*c/d;
out<< x <<" "<< y<<'\n';
}
}
return 0;
}