Pagini recente » Cod sursa (job #2705179) | Cod sursa (job #2516137) | Cod sursa (job #2587240) | Cod sursa (job #684234) | Cod sursa (job #2494610)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
void gcdextended(long long a, long long b, long long &d, long long &x, long long &y)
{
if(b==0){
x=1, y=0;
d=a;
}
else{
long long x1, y1;
gcdextended(b, a%b, d, x1, y1);
x=y1;
y=x1-(a/b)*y1;
}
}
int main(){
long long a, b, c, n;
fin>>n;
while(n--){
fin>>a>>b>>c;
long long x=0, y=0, d=0;
gcdextended(a, b, d, x, y);
if(c%d){
fout<<0<<" "<<0<<"\n";
}
else{
fout<<x*(c/d)<<" "<<y*(c/d)<<"\n";
}
}
return 0;
}