Pagini recente » Cod sursa (job #1540592) | Cod sursa (job #1520816) | Cod sursa (job #1286013) | Cod sursa (job #1614658) | Cod sursa (job #2937241)
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
int x,y,d;
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 n;
cin>>n;
int a,b,c;
for(int i=0;i<n;i++)
{
cin>>a>>b>>c;
euclid(a,b,d,x,y);
if(c%d!=0)
cout<<0<<" "<<0<<'\n';
else
{
int r=c/d;
cout<<x*r<<" "<<y*r<<'\n';
}
}
return 0;
}