Pagini recente » Cod sursa (job #1674145) | Profil PetrescuBianca | Cod sursa (job #646576) | Cod sursa (job #1623259) | Cod sursa (job #2553532)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int N;
void Euclid(int a, int b, int &d, int &x, int &y){
if(b==0){
d=a, x=1, y=0;
return;
}
int x0, y0;
Euclid(b,a%b,d, x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
int main(){
fin>>N;
for(int i=1;i<=N;++i)
{
int a,b, d, x,y;
int c;
fin>>a>>b>>c;
Euclid(a,b,d, x,y);
if(c%d==0)
fout<<x*c/d<<" "<<y*c/d<<"\n";
else fout<<0<<" "<<0<<"\n";
}
}